You must Sign In to post a response.
  • Category: SQL Server

    How to Change Runtime Database name in Trigger

    hi

    I have face a problem is this .

    i have n numbers of database .
    i want to change Database name at runtime in trigger (fire Insert row on table ) in sql server 2008. how to change the DB Name.


    Thank you.
  • #747023
    Hi,
    You can execute below query from your trigger,


    ALTER DATABASE oldDBName
    Modify Name = NewDBName;


    Just evaluate the implications of renaming the database at run time. None of the existing applications or connections to the database will work if you rename the Database.


    Regards,
    Asheej T K

  • #747025
    Use the below script to rename the database

    EXEC sp_renameDB 'oldDataBase','newDataBase'

    Regards
    Siva


  • Sign In to post your comments