Solved

Sysfiles name shows wrong database

Posted on 2008-06-19
1
436 Views
Last Modified: 2008-06-19
I've inherited a database that had relatively large log files. Datafiles: 23GB, 11GB, 9GB. Log files: 25GB, 13GB, 10GB. I wanted to get this fixed. I backed up the databases and then tried to run DBCC Shrinkfile. On database1 and 3 I had no problems. But on database2, it fails with "could not locate file 'database2' in sysfiles. I looked at sysfiles for database2 and the filename column points to database2.mdf and database2_log.ldf. However, the name column shows database1_dat and database1_log.

Will ALTER DATABASE resolve this?
0
Comment
Question by:evcevis
1 Comment
 
LVL 13

Accepted Solution

by:
MikeWalsh earned 250 total points
ID: 21827910
My guess here is that the logical/physical names got screwed up during a restore operation previously.

So you should be able to use Alter Database to modify your logical filename.

From BOL:

ALTER DATABASE test
MODIFY FILE
    (NAME = oldname, NEWNAME = newname);
GO

If you have an issue with the physical name you would just use the move command for that logical file and put the new path/name for the new physical name.


I know you didn't ask this, but I also would comment on the practice of shrinking files. It is generally a bad practice. Files grew to their size for a reason. If you go through the process of shrinking a file and it grows back you now have a performance hit during that growth and you are causing potential fragmentation and data access perf hits moving forward. When you shrink a log file and allow it to grow, that log file will now have more virtual log files which can also cause a performance hit.

I generally like to grow the files to the size I expect them to be for the next n months and set them once. Just food for thought. Paul Randal, formerly of the SQL Server Storage Engine team at Microsoft, blogs about this on his blog: http://www.sqlskills.com/blogs/paul/
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question