Friday, March 23, 2012

Rename database

Is there any simple way to rename database?
sp_renamedb
Look up the details in BOL (Books On-Line)
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Dolphin" <d@.d.com> wrote in message
news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
> Is there any simple way to rename database?
>
|||... or in SQL2K, ALTER DATABASE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Geoff N. Hiten" <SRDBA@.Careerbuilder.com> wrote in message news:u2KB8NdUEHA.760@.TK2MSFTNGP12.phx.gbl...
> sp_renamedb
> Look up the details in BOL (Books On-Line)
> --
> Geoff N. Hiten
> Microsoft SQL Server MVP
> Senior Database Administrator
> Careerbuilder.com
> I support the Professional Association for SQL Server
> www.sqlpass.org
> "Dolphin" <d@.d.com> wrote in message
> news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
>
|||Hi,
Ensure that no users are accessning the database. If accessing you will get
errors.
Use the below script to make the db single user , rename a database, set the
database to multi user.
Alter database <dbname> set single_user with rollback immediate
go
alter database <dbname> MODIFY NAME = <new_dbname >
go
Alter database <new_db_name> set multi_user
Thanks
Hari
MCDBA
"Dolphin" <d@.d.com> wrote in message
news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
> Is there any simple way to rename database?
>
|||Thanks for answers,
When I use "sp_renamedb" or "ALTER DATABASE" physical files names doesn't
change. Is it possible change db files_names?
"Dolphin" <d@.d.com> wrote in message
news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
> Is there any simple way to rename database?
>
|||Not easily. You can sp_detach_db and then sp_attach_db. Read about the commands in Books Online. Also, read KB
224071.
Another option is BACKUP/RESTORE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Dolphin" <d@.d.com> wrote in message news:eLBhaqfUEHA.1656@.TK2MSFTNGP09.phx.gbl...
> Thanks for answers,
> When I use "sp_renamedb" or "ALTER DATABASE" physical files names doesn't
> change. Is it possible change db files_names?
> "Dolphin" <d@.d.com> wrote in message
> news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
>
|||Hi,
SP_RENAMEDB will just channge database name. If you need to change the
physical names of
mdf and ldf files then:-
1. Execute SP_DETACH_DB <dbname> to detach the database
2. Rename the MDF and LDF files from windows explorer
3. Execute sp_attach_db <dbname>,'newmdf_name_with_
path','new_ldf_name_with_path'
Thanks
Hari
MCDBA
"Dolphin" <d@.d.com> wrote in message
news:eLBhaqfUEHA.1656@.TK2MSFTNGP09.phx.gbl...
> Thanks for answers,
> When I use "sp_renamedb" or "ALTER DATABASE" physical files names doesn't
> change. Is it possible change db files_names?
> "Dolphin" <d@.d.com> wrote in message
> news:uU7ukMdUEHA.2844@.TK2MSFTNGP12.phx.gbl...
>

No comments:

Post a Comment