我需要一个返回某些列的值的选择查询。我想要的列以“U_S”开头。
Select * from em
我需要转换上面的查询。'*' 需要是以下结果(但带逗号):
select COLUMN_NAME from information_schema.columns
where table_name='em' and column_name like 'u_s%'
有无数这样的例子,但我明白有时我们都需要一点点启动。
Select Stuff((Select ',' +quotename(Column_Name)
From information_schema.columns
Where table_name='em' and column_name like 'u_s%'
For XML Path ('')),1,1,'')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句