怎么样写删除表的相同字段的存储过程
beggy 2003-10-12 06:33:52 在一个数据库中有很多表,有很大一部分表都有bbs 这个字段,要删除这个字段,该怎么写存储过程?
我是这样写的:
CREATE PROCEDURE del_col
AS
declare @tblName varchar(100);
begin
declare a_cursor cursor
for
select [name] from sysobjects where xtype='u' and status>0
open a_cursor
fetch next from a_cursor into @tblName
Exec ('alter table '+@tblName+' DROP COLUMN bbs ')
while @@Fetch_status=0
begin
fetch next from a_cursor into @tblName
Exec ('alter table '+@tblName+' DROP COLUMN bbs ')
end
close a_cursor
deallocate a_cursor
end
GO