日期:2014-05-17 浏览次数:20453 次
declare @sql varchar(max) select @sql = isnull(','+@sql,'')+name from syscolumns where id=object_id( '表名称 ') and name <> 'photo ' set @sql = 'select ' + @sql + ' from 表名称 where ... ' exec(@sql)
------解决方案--------------------
declare @col varchar(1000) select @col=isnull(@col+',','')+name from syscolumns where id=object_id('表名') and name<>'排除的字段名' order by colid exec('select '+@col+' from 表名')