declare @name varchar(100)
declare @sql varchar(1000)
SET @sql='select '
DECLARE C11 CURSOR FOR
select name from syscolumns where id=
(select max(id) from sysobjects where xtype='u' and name='Album')//Album为表名
and name <> 'AlbumID'//AlbumID为要除去的表字段
OPEN C11
FETCH NEXT FROM C11 INTO
@name
IF @@FETCH_STATUS <> 0
BEGIN
DEALLOCATE C11
RETURN
END
WHILE(@@FETCH_STATUS = 0)
BEGIN
SET @sql=@sql+@name+','
FETCH NEXT FROM C11 INTO
@name
END
DEALLOCATE C11
set @sql=substring(@sql,1,len(@sql)-1)+' from Album'//Album为表名
exec (@sql)
图片如下: