Could not locate file ‘xy_abc_Log’ for database ‘abc’ in sys.database_files.

Problem – I have found VLF size of my database abc is very huge and when i have tried to shrink the file i have received below error –

Could not locate file ‘xy_abc_Log’ for database ‘abc’ in sys.database_files.

Resolution –

While my investigation I have found logical fine name under sys.master_files is different as compare to sys.database_files.

select name from sys.master_files where database_id = db_id(‘abc’)

xy_abc_Data
xy_abc_STAGE_Log

select name from sys.database_files

xy_abc_Data
xy_abc_Log

You will find logical name is different hence you need to update logical file name in sys.master_files table.

use [abc]

go

ALTER DATABASE [abc] MODIFY FILE (NAME=N’xy_abc_Log’, NEWNAME=N’xy_abc_Log’)
GO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s