更改所选列的列名称

时间:2017-10-25 04:40:24

标签: sql sql-server

我需要将所选列作为InspectionReportId。执行以下查询时,输出和列名称未正确显示。

 SELECT
     CONVERT(VARCHAR(100), Id) + '~' + CONVERT(VARCHAR(100), 19021) + '|' AS InspectionReportId
 FROM 
     OBJ_SystemPanelInspectionReports  
 WHERE
     SystemId = 19021  
 FOR XML PATH ('')

1 个答案:

答案 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]