Hi Friends,
I want to know How to change Database name in SQL Server ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MuthuMari MPosted May 10, 2012, 1:33 AM
use this line,
sp_renamedb 'oldDBName', 'newDBName'
pls refer this url
http://www.mssqltips.com/sqlservertip/1122/how-to-rename-a-sql-server-database/
thanks
If this post is useful then mark it as "Accepted Answer"
Jignesh TrivediPosted May 10, 2012, 12:13 AM
to rename database you have three option.
Option 1:Use the following T-SQL(command to make the database name change0.
EXEC sp_renamedb 'oldName', 'newName'
OR
ALTER DATABASE oldName MODIFY NAME = newName
This new command that should be used for SQL Serer 2005 and beyond.
Option 2
If you are using SQL Server Management Studio, right click on the database name and select the option "rename".
Option 3
Use the detach and attach feature of SQL Server to detach the database first and when you reattach the database you give the database a different name. This can be done by using the GUI or you can do this by using the following commands:
EXEC sp_detach_db 'oldDBName', 'true'
EXEC sp_attach_db @dbname = N'newDBName', @filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf', @filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'
hope this help.
Satyapriya NayakPosted May 9, 2012, 10:07 PM
Supported in SQL Server 2000 and 2005
exec sp_renamedb "test", "test1"
Supported in SQL Server 2005 and later version
ALTER Database "test1" Modify Name="test"
Thanks