日期:2014-05-17 浏览次数:20911 次
declare @sql varchar(4000)
select @sql=isnull(@sql,'')+','+name from sys.columns
where object_id in (select object_id from sys.tables where name ='table1') and name !='a25'
set @sql=STUFF(@sql,1,1,'')
exec ('select ' + @sql+' from table1')
Declare @sql nvarchar(max)
Select @sql=isnull(@sql+',','')+quotename(name) From sys.syscolumns
Where id=object_id('table1')
And name Not in('a25')
Exec ('Select '+@sql+' From table1')