我需要将所选列作为InspectionReportId。执行以下查询时,输出和列名称未正确显示。
SELECT
CONVERT(VARCHAR(100), Id) + '~' + CONVERT(VARCHAR(100), 19021) + '|' AS InspectionReportId
FROM
OBJ_SystemPanelInspectionReports
WHERE
SystemId = 19021
FOR XML PATH ('')
答案 0 :(得分:0)
在StackOverflow上发现{{3}}
您可以SELECT ( ... ) AS [YourColumnName]
SELECT (
SELECT
CONVERT(VARCHAR(100), Id) + '~' + CONVERT(VARCHAR(100), 19021) + '|' AS InspectionReportId
FROM
OBJ_SystemPanelInspectionReports
WHERE
SystemId = 19021
FOR XML PATH ('')
) AS [YourColumnName]