sql 查询除某字段的其他字段的记录

终于找到了排除字段查询的方法了 。之前老是被人问倒。

declare @field nvarchar(1000)
select @field=isnull(@field+',','')+quotename(Name) from syscolumns where ID=object_id('表名') and Name not in('排除1','排除2') 
exec('select '+@field+' from 表名')
View Code
原文地址:https://www.cnblogs.com/ybyi/p/3228425.html