sql数据库中批量删除多个表的多个字段
例子,批量删除多个表的多个字段的sql语句。
declare @tablename varchar(30)
DECLARE cur_temp Cursor For
select b.name from dbo.syscolumns a,dbo.sysobjects b
where a.name = colname --要删的字段
and a.id = b.id
and b.type = 'U'
OPEN cur_temp_memid
FETCH cur_tempd Into @tablename
while @@fetch_status = 0
begin
exec('alter table '+@tablename+' drop column colname')
FETCH cur_temp Into @tablename
end
Close cur_temp
Deallocate cur_temp