This blog shares my journey as a software engineer, along with personal reviews and life experiences I’ve gained along the way. “I have not failed. I've just found 10,000 ways that won't work.” — Thomas Edison. If you enjoy my content, please support it by clicking on ads (free for you, big help for me!) or by buying me a coffee on Ko-fi. Thank you!
Tuesday, March 12, 2013
T-SQL Library - Check if Column Exists Alter Table
Composing T-SQL to run over and over to check into source control for column change....
IF NOT EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tbl_Provider_Concerns'
AND COLUMN_NAME = 'concern_status_id')
BEGIN
ALTER TABLE tbl_Provider_Concerns
ADD concern_status_id INT
END
ALTER TABLE tbl_Provider_Concerns
ADD CONSTRAINT FK_Status
FOREIGN KEY(concern_status_id)
REFERENCES tbl_Provider_Concern_Status(concern_status_id)
No comments:
Post a Comment