--用游标
declare @name varchar(100)
declare t_cursor cursor for
select name from sysobjects where type='U' and name!='dtproperties'open t_cursorfetch next from t_cursor into @namewhile @@fetch_status=0
begin
    if not exists(select 1 from syscolumns where id=object_id(@name) and name='更新日期')
        exec('alter table '+@name+' add 更新日期 datetime')
        
    if not exists(select 1 from syscolumns where id=object_id(@name) and name='更新人')
        exec('alter table '+@name+' add 更新人 varchar(20)')
        
    ...
        
    fetch next from t_cursor into @name
endclose t_cursor
deallocate t_cursor