DBCC Shrinkfile

  • I wanted to shrink a file to 100MB, when I ran this query:

    dbcc shrinkfile ('D:\MSSQL\data\Alert.mdf',100)   

    I go this error:

    Server: Msg 8985, Level 16, State 1, Line 1

    Could not locate file 'D:\MSSQL\data\Alert.mdf' in sysfiles.

    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    When I did a select on sysfiles table only the files for master database are in this table.But, there is another table called sysaltfiles that has all the data files and log files of all the databases.

    Any idea?

    Your help will be appreciated.

    Thanks,

    Ariana

     

  • I was running the query on the master and not the userdb.

  • Please do not pass the physical file name as parameter.

    The Syntax of DBCC SHRINKFILE states that pass the logical file name or id without including in quotations.

    Try out.

    Bye

  • here are the steps for executing the DBCC SHRINKFILE:

    1. find out what is the logical name of the file that you want to shrink. You can use SP_HELPFILE to find out this. (in resultset see name column)

    2. then execute the command like this :

    DBCC SHRINKFILE ( Logicalfilename, NN%) -- here NN% is the free space left in the file.

  • what about going to EM .. then right click on your DB .. then choose (All Tasks) >> (Shronk DB)

    then click on files and choose shrink file too the percentage you want

    i hope this help u


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply