?
Solved

Sysfiles name shows wrong database

Posted on 2008-06-19
1
Medium Priority
?
440 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
MikeWalsh earned 1000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

764 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