Wednesday, March 28, 2012

Renaming a database

I've renamed a database using the sp_rename but now I
notice that the mdf file is still named oldDBname.mdf.
Is there a way to rename that file to newDBname.mdf?Renaming the database does not change the physical name of the file. To do that you will have to
use system stored procedure sp_detach_db and sp_attach_db.
An approximate sequence of the steps to be taken would be something like this:
detach the db using sp_detach_db
rename the physical files.
use sp_attach_db stored procedure to attach these rename files.
See more help on this in BOL.
--
- Vishal
"mark" <mhoyt@.affiliatedhealth.org> wrote in message news:02c601c38dc5$c37c8fe0$a301280a@.phx.gbl...
> I've renamed a database using the sp_rename but now I
> notice that the mdf file is still named oldDBname.mdf.
> Is there a way to rename that file to newDBname.mdf?|||Try backup and restore.
/Stefan
"mark" <mhoyt@.affiliatedhealth.org> skrev i meddelandet
news:02c601c38dc5$c37c8fe0$a301280a@.phx.gbl...
> I've renamed a database using the sp_rename but now I
> notice that the mdf file is still named oldDBname.mdf.
> Is there a way to rename that file to newDBname.mdf?|||Vishal:
How about if I want to change the logical name also?
Thanks
"Vishal Parkar" <_vgparkar@.hotmail.com> wrote in message
news:uyhhcdcjDHA.2364@.TK2MSFTNGP11.phx.gbl...
> Renaming the database does not change the physical name of the file. To do
that you will have to
> use system stored procedure sp_detach_db and sp_attach_db.
> An approximate sequence of the steps to be taken would be something like
this:
> detach the db using sp_detach_db
> rename the physical files.
> use sp_attach_db stored procedure to attach these rename files.
> See more help on this in BOL.
> --
> - Vishal
> "mark" <mhoyt@.affiliatedhealth.org> wrote in message
news:02c601c38dc5$c37c8fe0$a301280a@.phx.gbl...
> > I've renamed a database using the sp_rename but now I
> > notice that the mdf file is still named oldDBname.mdf.
> >
> > Is there a way to rename that file to newDBname.mdf?
>|||In SQL 2000, you can use ALTER DATABASE command to change the logical name of the file.
Ex:
alter database northwind modify file
(name = 'northwind', newname = 'northwind_new')
- Vishal|||great.
"Vishal Parkar" <_vgparkar@.hotmail.com> wrote in message
news:%23mbcjrcjDHA.2268@.TK2MSFTNGP12.phx.gbl...
> In SQL 2000, you can use ALTER DATABASE command to change the logical
name of the file.
> Ex:
> alter database northwind modify file
> (name = 'northwind', newname = 'northwind_new')
>
> --
> - Vishal
>|||and how we do this using Enterprise Manager. I openend the properties of
databse but I didn't find any option to rename the logical filename ?
"Vishal Parkar" <_vgparkar@.hotmail.com> wrote in message
news:%23mbcjrcjDHA.2268@.TK2MSFTNGP12.phx.gbl...
> In SQL 2000, you can use ALTER DATABASE command to change the logical
name of the file.
> Ex:
> alter database northwind modify file
> (name = 'northwind', newname = 'northwind_new')
>
> --
> - Vishal
>|||you cant do this through enterprise manager.
--
- Vishal
"Sender" <user@.domain.com> wrote in message news:OcNl6ycjDHA.2268@.TK2MSFTNGP12.phx.gbl...
> and how we do this using Enterprise Manager. I openend the properties of
> databse but I didn't find any option to rename the logical filename ?
>
> "Vishal Parkar" <_vgparkar@.hotmail.com> wrote in message
> news:%23mbcjrcjDHA.2268@.TK2MSFTNGP12.phx.gbl...
> > In SQL 2000, you can use ALTER DATABASE command to change the logical
> name of the file.
> > Ex:
> > alter database northwind modify file
> > (name = 'northwind', newname = 'northwind_new')
> >
> >
> > --
> > - Vishal
> >
> >
>

No comments:

Post a Comment