10/29/2022 0 Comments Sql server rename column![]() ![]() OrderDate DATETIME CONSTRAINT DEFAULT (GETDATE()) NOT NULL,ĬONSTRAINT PK_OrderInfo_Id PRIMARY KEY NONCLUSTERED (Id ASC)ĬREATE NONCLUSTERED INDEX IX_OrderInfo_OrderMode ON dbo.OrderInfo (OrderMode)īefore snapshot of table, constraints, and index. OrderMode VARCHAR(20) CONSTRAINT CHECK (OrderMode IN ('ONLINE','OFFLINE')) NOT NULL, We will compare before and after snapshots. To demonstrates this, I am creating a table with Primary key, check constraint, non-clustered index and putting some data into this table. You can rename below objects using sp_rename:ĭefault value for this parameter is TABLE When renaming a column you need to specify table lumn name optionally you can also prefix schema name for the specified of the object. Reference has been taken from Microsoft documentation. This approach is recommended because we can run pre-deployment scripts in the environment before deploying these changes. The best and easiest way is to use SP_RENAME, a build-in stored procedure to rename these objects. To solve this problem, you may need to rename existing database objects like table name, column name, store procedure name, etc. The database objects which were originally designed may not match the current business objects. ![]() You may have faced a scenario where sometimes we need to rename database objects to specify correct business significance and meaning to the system on production code. This article demonstrates how we can easily rename various database objects like Tables, Columns, Constraints, Indexes, SP in SQL Server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |