... declare a_cursor cursor for select b.name from syscolumns a join sysobjects b on a.id=b.id where a.name='bbs' and b.xtype='U" and b.status>0 open a_cursor ...
CREATE PROCEDURE del_col AS declare @a varchar(255)begindeclare a_cursor cursor for select d.name from syscolumns a,sysobjects d where a.id=d.id and d.xtype='U' and a.name='bbs' open a_cursor fetch next from a_cursor into @a while @@Fetch_status=0 begin Exec ('alter table '+@a+' DROP COLUMN bbs ') fetch next from a_cursor into @a endclose a_cursor deallocate a_cursorend GO
...
declare a_cursor cursor
for
select b.name from syscolumns a join sysobjects b on a.id=b.id where a.name='bbs' and b.xtype='U" and b.status>0
open a_cursor
...
AS
declare @a varchar(255)begindeclare a_cursor cursor for select d.name from syscolumns a,sysobjects d where a.id=d.id and d.xtype='U' and a.name='bbs'
open a_cursor
fetch next from a_cursor into @a
while @@Fetch_status=0
begin
Exec ('alter table '+@a+' DROP COLUMN bbs ')
fetch next from a_cursor into @a
endclose a_cursor
deallocate a_cursorend
GO