DBCC ShrinkFile from GUI debate. How does this work?

  • A coworker and I were reclaiming some trans log space for some soon to be deleted development DB's. We decided to run a truncate log and then shrink db on the logs followed by full backups. Being lazy I used the GUI to script out a shrink log file command.

    DBCC SHRINKFILE (N'MyLogFile_log' , 0) -- from GUI

    Now my coworker tells me this won't work and has me look up the file id from sys.database_files which according to BOL is how you should find the correct id.

    http://technet.microsoft.com/en-us/library/ms189493.aspx

    DBCC SHRINKFILE (N'MyLogFile_log' , 2) -- Uses sys.database_files for file id.

    Now we ran one version using the GUI generated tool on one DB and another DB did the lookup for file id and ran that version. Both work but we can't find any documentation on why the GUI tool always scripts "0" for the FileID and what makes this work. Anyone that can satisfy our curiosity?

  • you can either state the file name or the file id,

    by using the filename then a comma and the file id it would mean that you are specifying the targetsize rather than the id.

  • thanks Steve just as you posted i realized what you said. We were viewing the target size as the fileid.....doh! too late in the day i guess. Thank you!

Viewing 3 posts - 1 through 2 (of 2 total)

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