日期:2014-05-16 浏览次数:21539 次
DECLARE @s NVARCHAR(4000)
SET @s = ''
SELECT @s = @s + ',' + 'isnull('+QUOTENAME(name)+','''')'
FROM syscolumns
WHERE id = OBJECT_ID('表名')
--AND name NOT IN ( '不希望显式的列' )
SET @s = STUFF(@s, 1, 1, '')
EXEC('select '+@s+' from 表名 ')
SELECT * FROM syscolumns WHERE name NOT IN(.....) AND id=object_id('表名')