Sunday, 1 June 2014

SQL Post 6 (Database Re Naming)


Sometime there is a need to change the database name in SQL. There could be multiple reasons where DBA can face this situation.
1) Project name got changed and DBA has to change the Database Name
2) DBA is restoring is database name as temp datbase and need to change the database name
SQL Server provides couple of options to rename the database.
Rename the database name from SSMS
1) Open SSMS
2) Select Database Name and Right Click
3) Select ReName Option
*********************************************************************
 Rename the database name from Attach and De Attach
1) Open SQL Server Query Analyzer
2) Exec sp_detech_db 'Old_Database_Name','true'
3) Exec sp_attach_db @dbname='New_Database_Name'
                                          @File_Name1='Provide path of MDF file Name'
                                          @File_Name2='Provide path of LDF file Name'
*********************************************************************
Rename the database name from Query
1) Open SQL Server Query Analyzer
2) Sp_renamedb 'old_database_name','New_Database_Name'
*********************************************************************
Keep Reading and Happy Monday
Sanjay Bakshi
                               
                                          
 
 
 

No comments:

Post a Comment