Rename logical database name | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Rename logical database name

I want to rename logical database name but the following doesn’t let me do that. Do you have any alternative? EXEC sp_Configure @ConfigName = ‘allow updates’, @ConfigValue = 1
RECONFIGURE WITH OVERRIDE
GO UPDATE SysFiles SET name = ‘MyDB_data’ where name = ‘TestDB_dat’
GO
UPDATE SysFiles SET name = ‘MyDB_log’ where name = ‘TestDB_log’
GO Exec sp_Configure @ConfigName = ‘allow updates’, @ConfigValue = 0
RECONFIGURE WITH OVERRIDE
GO
CanadaDBA
Its not recommended to update system tables directly, use ‘alter database’ statement to change logical names of files: – For Example: –
USE master
GO
ALTER DATABASE Test1
MODIFY FILE
(NAME = TestDB_dat, NEWNAME=MyDB_Data)
GO — Check FileSpecifications from BOL’s Alter database for more informations ( NAME = logical_file_name
[ , NEWNAME = new_logical_name ]
[ , FILENAME = ‘os_file_name’ ]
[ , SIZE = size ]
[ , MAXSIZE = { max_size | UNLIMITED } ]
[ , FILEGROWTH = growth_increment ] ) Deepak Kumar –An eye for an eye and everyone shall be blind
Thats correct , do not modify directly system tables, use Alter command instead AKTHAR DILMOHAMUD
65 BENARES ST
PORT LOUIS
MAURITIUS
or other way is to use Detach, rename the file and Attach again, i think this works[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />AKTHAR DILMOHAMUD<br />65 BENARES ST<br />PORT LOUIS<br />MAURITIUS
]]>