日期:2014-05-17 浏览次数:20597 次
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,@c
while(@@fetch_status<>-1)
begin
select @tsql='alter table '+@t+' drop column '+@c
exec(@tsql)
fetch next from gz into @t,@c
end
close gz
deallocate gz