我的存儲過程是:轉換失敗
CREATE PROCEDURE [dbo].[USP_GET_MBR_DWN_DTL] (@MBR_ID VARCHAR(50), @LEG_POS CHAR)
AS BEGIN
WITH CTE(MBR_ID, MBR_LEG_POS, MBR_NM, MBR_JOIN_TT, LVL, MBR_UPR_ID, MBR_SPR_ID) AS
(
SELECT
CAST(MBR_ID AS VARCHAR(100)) as MBR_ID,
MBR_LEG_POS, MBR_NM, MBR_JOIN_TT,
CAST(MBR_UPR_ID AS VARCHAR(100)) as MBR_UPR_ID,
CAST(MBR_SPR_ID AS VARCHAR(100)) as MBR_SPR_ID,
LVL=0
FROM MBR_MST
WHERE [email protected]_ID and [email protected]_POS
UNION ALL
SELECT
CAST(M.MBR_ID AS VARCHAR(100)) as MBR_ID,
M.MBR_LEG_POS,M.MBR_NM,M.MBR_JOIN_TT,
CAST(M.MBR_UPR_ID AS VARCHAR(100)) as MBR_UPR_ID,
CAST(M.MBR_SPR_ID AS VARCHAR(100)) as MBR_SPR_ID,
LVL+1
FROM MBR_MST M
JOIN CTE F ON CAST(M.MBR_UPR_ID AS VARCHAR(100))=CAST(F.MBR_ID AS VARCHAR(100))
)
SELECT * FROM CTE ORDER BY LVL, MBR_JOIN_TT OPTION (MAXRECURSION 0)
END
但是當我運行
USP_GET_MBR_DWN_DTL 'Flife1', 'A'
它顯示錯誤
消息245,第16層,狀態1,程序USP_GET_MBR_DWN_DTL,第5行
轉換失敗轉換varchar v將'Flife1'轉換爲數據類型int。
請幫助..這對我造成很多問題.. – Nisar
MBR_UPR_ID和MBR_LEG_POS的類型是什麼? –