rename the sql server 2005 database

  • I am trying to rename the database using below command

    ALTER DATABASE TEST3.3_STAGING MODIFY NAME = TEST3_3_STAGING

    throwing below error

    Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near '.3'.

    please advice

  • try putting square brackets [] around the database names

    ---------------------------------------------------------------------

  • Great!

    it worked

    Thank you very much

  • Hi,

    If anybody connected to the database. you cannot rename the database.

    First you should kill the all users, afterwards you can rename the database.

    Alter database databasename set single_user with rollback immediate

    You can executes the abopve query, all the users will kill it.

    Afterwards you can use this below query.

    sp_renamedb olddatabasename,newdatabasename

    With Thanks & Regards

    Balaji.G

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply