declare @sql varchar(200), @name varchar(40)
declare my_cursor scroll cursor for
select name from sysobjects where type = 'u' and name like '%表名(相似表)%'
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 需要增加的字段 字段类型'
exec(@sql)
print 'finished'
fetch next from my_cursor into @name
end
close my_cursor
deallocate my_cursor