當我試圖檢索這個數據,它的工作原理。Concat字符串到INT在SQL服務器.-但獲取錯誤
SELECT
CONVERT(VARCHAR(10),BH.Doc_Date,(120))AS Doc_Date
,LGH.Node_Code
,LGH.Node_Name AS Location_Name
,GD.Nationality
,GD.Guest_Name
,DBOGD.Name AS Gender
,CAST(DATEDIFF(yy,GD.Birth_Day,getdate()) AS NVARCHAR(100)) + ' yrs' AS Age
,'++' + CAST(GD.Mobile AS VARCHAR(100)) AS Mobile
,GD.NIC_No
,GD.Language
FROM [booking].[Guest_Details] AS GD ...
但是,當我試圖做這樣的,
SET @query = 'SELECT
CONVERT(VARCHAR(10)
,BH.Doc_Date,(120))AS Doc_Date
,LGH.Node_Code
,LGH.Node_Name AS Location_Name
,GD.Nationality
,GD.Guest_Name
,DBOGD.Name AS Gender
,(CAST(DATEDIFF(yy,GD.Birth_Day,getdate()) AS NVARCHAR(100)) + " yrs") AS Age
,"++" + CAST(GD.Mobile AS VARCHAR(100)) AS Mobile
,GD.NIC_No
,GD.Language
FROM [booking].[Guest_Details] AS GD ...'
它不工作。我出現如下錯誤:
列名'yrs'無效。
無效的列名'++'。
爲什麼有你切換到「語音標記,而不是「? –
代替雙引號「」',使用兩個單引號'‘’' – Arulkumar
我用單引號也試過。但它沒有奏效。 – TKrish