how to rename sql database code example
Example 1: sql server rename database
ALTER DATABASE MyTestDatabase MODIFY NAME = MyTestDatabaseCopy ;
Example 2: alter database name script
USE master;
GO
ALTER DATABASE MyTestDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE MyTestDatabase MODIFY NAME = MyTestDatabaseCopy ;
GO
ALTER DATABASE MyTestDatabaseCopy SET MULTI_USER
GO
Example 3: how to rename columns in sql server
EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN';