我想知道如何在像这样的动态查询的结果中过滤(放置where子句):
execute(@query)问题是@query的列数是动态的,标题是未知的,因为查询是透视的结果:
TSQL creating a dynamic report from two tables, one table is holds the headers, other one, data
我想得到的结果是这样的:
select * from execute(@query) where column(1) = 'something'提前感谢您的帮助。
发布于 2013-02-23 21:09:41
set @query = N'select * from (' + @query + N') t where [col1] = ''something''';
exec (@query)您可以使用未透视的表来确定列的名称,并使用它来代替col1。
https://stackoverflow.com/questions/15040773
复制相似问题