如何列出查询的所有字段名称,如下所示:
table1.field1
,table1.field2
,table1.field3
,table2.field1
,table2.field2
etc
来自这个选择语句:
Select
*
from
Status s
Inner Join Residents r
ON r.RES_ID = s.RES_ID
Left Join REPSResidents rr
ON rr.MainPeopleIDY = r.RES_PeopleIDY
Inner Join Associate u
ON s.STA_User = u.USR_ID
Inner Join KSLSQL1.[RPS-201065-000].dbo.people p
ON r.RES_PeopleIDY = p.PeopleIDY
Where.......
我的问题是在SSRS中,我不能只执行select *
,因为多个表中有多个字段会重复。
所以我需要一个包含所有返回字段的列表。
这可能吗?
答案 0 :(得分:1)
SELECT t.name +'_' + c.name
FROM sys.columns c INNER JOIN
sys.tables t ON c.object_id = t.object_id
WHERE t.name = 'Residents'