sysfiles has wrong info for DB

  • This server host a production copy and test copy of the DB. There are files for both DBs live and test. When I run select name from sysfiles for the test DB it returns file names for the live DB. The live DB returns the correct file names. Could the test DB be running off of the live files also? And how do I correct this problem? I found this out because I need to shrink the log file.

    Thanks

    Frank

  • Frank,

    Are you talking about the Name field which is the logical name and could be the same or about Filename field which is a path and should be different?

    Regards,Yelena Varsha

  • Hopefully, this will clear it up because it is confusing me. I ran DBCC Shrinkfile and it would return that it could not find the log file. So I ran the 'select name from sysfiles' command and it returned the file names for the live database and not the test database which I was working with. I believe that is the logical name is what it returns. So am I overreacting to this? How do I shrink the log file then?

    Thanks for the help.

    Frank

  • I ran select filename from sysfiles and it did return the correct file path and files for the test DB. So it is just the logical name itself that is goofed up. That is what I need to fix so I can shrink the log file.

    Thanks

    Frank

  • This can get very confusing as you move databases around.  To correct the problem use this command:

    alter database dbname  MODIFY FILE (NAME = logical_file_name, NEWNAME = 'new_logical_name')

    You don't have to correct the name to shrink the files.

    Aunt Kathi Data Platform MVP
    Author of Expert T-SQL Window Functions
    Simple-Talk Editor

  • Worked like a charm.

    Thanks

    Frank

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

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