--寫好了,你把“除外的欄位”還有“表名”都填寫好。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="表名")
and name <> "除外的欄位"
OPEN C11
FETCH NEXT FROM C11 INTO
@name
IF @@FETCH_STATUS <> 0
BEGIN
DEALLOCATE C11
RETURN
END
WHILE(@@FETCH_STATUS = 0)
SET @sql=@sql+@name+","
set @sql=substring(@sql,1,len(@sql)-1)+" from 表名"
exec (@sql)
--寫好了,你把“除外的欄位”還有“表名”都填寫好。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="表名")
and name <> "除外的欄位"
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 表名"
exec (@sql)