我有以下SQL語句:SQL選擇帶有功能
SELECT
RTRIM(LTRIM(REPLACE(LAGKART.VARENUMMER,CHAR(2),''))) AS ItemNo,
RTRIM(LTRIM(REPLACE(LAGKART.SXSON,CHAR(2),''))) AS Season,
ISNULL(RTRIM(LTRIM(REPLACE(LAGKART.VARIANT1,CHAR(2),''))),'') AS Variant1,
ISNULL(RTRIM(LTRIM(REPLACE(LAGKART.VARIANT2,CHAR(2),''))),'') AS Variant2,
(SELECT *
FROM [dbo].[B2BGetSpringFinal] (LAGKART.VARENUMMER,
LAGKART.VARIANT1,
LAGKART.VARIANT2
)) AS SpringAvailable
FROM
LAGKART
但我得到這個錯誤:
消息170,級別15,狀態1,行8
附近有語法錯誤''。
但如果我叫具有固定值的功能:
SELECT
RTRIM(LTRIM(REPLACE(LAGKART.VARENUMMER,CHAR(2),''))) AS ItemNo,
RTRIM(LTRIM(REPLACE(LAGKART.SXSON,CHAR(2),''))) AS Season,
ISNULL(RTRIM(LTRIM(REPLACE(LAGKART.VARIANT1,CHAR(2),''))),'') AS Variant1,
ISNULL(RTRIM(LTRIM(REPLACE(LAGKART.VARIANT2,CHAR(2),''))),'') AS Variant2,
(SELECT *
FROM [dbo].[B2BGetSpringFinal] ('6261',
'Black',
'S'
)) AS SpringAvailable
FROM
LAGKART
我得到了想要的結果。
任何想法?
溴 的Mads
這是什麼方言? TSQL?它看起來有點怪異,但不夠瘋狂,以防止MySQL。我很確定你不能把結果列拉到子查詢中,或者你想要一個CTE? – Jasen 2014-12-06 07:42:13
這是T-SQL 認爲你是對的,我不能在子查詢中使用結果列。 – Dauer 2014-12-06 07:46:59