DECLARE @tablename varchar (200)
DECLARE @sql varchar (2000)
DECLARE cur_t cursor FOR
Select name from sysobjects where xtype= ' U ' and status> =0 and name is not in (select name from sysobjects where ID in ( Select ID from syscolumns
where ID in (select id from sysobjects where type= ' U ')
and Name= ' Createtime '))
Open cur_t
FETCH NEXT from cur_t to @tablename
While @ @FETCH_STATUS = 0
Begin
Set @sql = ' ALTER TABLE ' + @tablename + ' Add createtime datetime '
EXEC (@sql)
FETCH NEXT from cur_t to @tablename
End
Close cur_t
Deallocate cur_t
Above is the Insert Createtime field in all Tables without createtime field, add other fields to modify Createtime
Select name from sysobjects where ID in (SELECT ID from syscolumns
where ID in (select id from sysobjects where type= ' U ')
and Name= ' Createtime ')
Querying for table names with createtime fields in all tables in the database
Select id from sysobjects where type= ' U '
Query all table IDs change the ID to name to find out all the table names
Insert fields in all SQL data tables