Friday, July 5, 2013

Check Column exists in table, if not, add


Check For a Column Exists In A Table If Not Add

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TableName' AND COLUMN_NAME ='ColumnName')

BEGIN

ALTER TABLE TableName ADD ColumnName varchar(50) NULL

END

3 comments:

  1. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. script cek mutasi

    ReplyDelete
  2. This post is a lifesaver for someone like me who's just starting to learn ETL concepts. The explanation of null handling in join conditions (and how to replace nulls with default values to make them match) really cleared things up. I'm building my data skills step by step, and I recently enrolled in a beginner data science course in electronic city bangalore to learn Python, statistics, and data manipulation from the ground up. Posts like yours make complex topics accessible. Thanks for sharing such a well-organized tutorial — looking forward to more!

    ReplyDelete