Posts Tagged ‘ Rename Database ’

Rename SQL Server 2005 Database and Datafile

Some of this SQL Commands don’t work in SQL Server 2000.


use master;

ALTER DATABASE Cheque_Req MODIFY FILE (NAME =Cheque_Req_Data, FILENAME = 'C:\ABC.MDF')
ALTER DATABASE Cheque_Req MODIFY FILE (NAME =Cheque_Req_Log, FILENAME = 'C:\ABC.LDF')


ALTER DATABASE Cheque_Req MODIFY FILE (NAME =Cheque_Req_Data, NEWNAME = 'cib')
ALTER DATABASE Cheque_Req MODIFY FILE (NAME =Cheque_Req_Log, NEWNAME = 'cib_log')

alter database Cheque_Req set offline;
-- copy existing data and log file and placed in new desired location
alter database Cheque_Req set online;

ALTER DATABASE Cheque_Req Modify Name = cibDB; 

Thanks
A Rahim Khan