Created
February 4, 2021 18:55
-
-
Save BrianMRO/7c6efe74d9ce372ba30d04dd87128b48 to your computer and use it in GitHub Desktop.
Refactor OwnerID - Step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [MyDatabase] | |
GO | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
IF COL_LENGTH('dbo.XXMyTable', 'OldOwnerID') IS NULL | |
BEGIN | |
EXEC sp_rename 'XXMyTable.OwnerID', 'OldOwnerID', 'COLUMN'; | |
ALTER TABLE XXMyTable ADD OwnerID INT NULL; | |
END | |
IF COL_LENGTH('dbo.XXMyTable', 'OldProductManagerID') IS NULL | |
BEGIN | |
EXEC sp_rename 'XXMyTable.ProductManagerID', 'OldProductManagerID', 'COLUMN'; | |
ALTER TABLE XXMyTable ADD ProductManagerID INT NULL; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment