EXEC sp_MSforeachtable ' if not exists (select * from sys.columns where object_id = object_id(''?'')and name = ''CreatedOn'') begin TER TABLE ? ADD CreatedOn datetime NOT NULL DEFAULT getdate(); end';This code snippet is for to Add a column if it doesn't exist to all tables.
