Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Refactor OwnerID - Step 1
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