try this,declare @tsql varchar(6000),@t varchar(50),@c varchar(50)declare gz cursor forward_only static for select b.name 'tabname',a.name 'colname' from sys.columns a inner join sys.tables b on a.object_id=b.object_id where a.name='[某个字段]'open gz fetch next from gz into @t,@cwhile(@@fetch_status<>-1) begin select @tsql='alter table '+@t+' drop column '+@c exec(@tsql) fetch next from gz into @t,@c endclose gz deallocate gz
static for
select b.name 'tabname',a.name 'colname'
from sys.columns a
inner join sys.tables b on a.object_id=b.object_id
where a.name='[某个字段]'open gz
fetch next from gz into @t,@cwhile(@@fetch_status<>-1)
begin
select @tsql='alter table '+@t+' drop column '+@c
exec(@tsql)
fetch next from gz into @t,@c
endclose gz
deallocate gz