假设某表有很多字段a,b,。。。。
select * from tb 可以取出所有字段
但是目前不需要a字段,其余全要,有简便方法吗?
DECLARE @collist NVARCHAR(1000)
SELECT @collist = ISNULL(@collist+',', '')+QUOTENAME(name)
FROM syscolumns
WHERE id = OBJECT_ID('tb')
AND name<>'a'
ORDER BY colid
EXEC ('SELECT '+@collist+' FROM tb')