Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shrinkfile - multiple databases with same logical name 1

Status
Not open for further replies.

leishad

Technical User
Apr 3, 2003
88
US
I found thread962-1080316 to provide most of what I need
however I was left with a question

With regard to shrinking Log Files the above thread illudes to the
following statement:
---------------------------------------
use {Database}
dbcc shrinkfile ({LogFileName}, {SizeToShrinkTo})
---------------------------------------
My understanding of the above is that {LogFileName} is the name that I get when I type in:

select name
from {database}.dbo.sysfiles
---------------------------------------
Among my many databases several use the same logical name.

Does the 'use {Database}' portion above ensure that the system uses
the {LogFileName} associated with the specified database even though
the same name is associated with other databases?
 
Hi,

In Enterprise Manager, right click your DB > Properties > Transaction Log.

This will give you the name of your log file for that specific DB.

When you execute dbcc shrinkfile for you log file, SQL Server checks the sysfiles entry within the current DB, so by issuing the USE MyDB statement, you are telling SQL Server to look for the file in that DB.

If it cant find yourdb_log in sysfiles, it returns an error.

Hope this helps.


Cheers,
Leigh

You're only as good as your last backup!
 
Sorry, forgot to say, in your situation with multiple DB's sharing the same file names, make sure you issue the USE MyDB statement each time you run DBCC SHRINKFILE to ensure you shrink the correct one.

From a performance point of view, take a look at the size of your log files, and try to establish an optimum size as shrinking and growing will impact on system performance.

Hope this helps.




Cheers,
Leigh

You're only as good as your last backup!
 
Thank-you, that is exactly the clarification I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top