declare @sql varchar(200), @name varchar(40)
declare my_cursor scroll cursor for
select name from sysobjects where type = 'u'
open my_cursor
fetch next from my_cursor into @name
while(@@fetch_status=0)
begin
print 'processing ' + @name
set @sql = N'alter table ' + @name + ' add db_timestamp datetime' //db_timestamp 我添加的字段名 及字段类型
exec(@sql)
print 'finished'
fetch next from my_cursor into @name
end
close my_cursor
deallocate my_cursor