我的存储过程是:
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 MBR_UPR_ID=@MBR_ID and MBR_LEG_POS=@LEG_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 值“Flife1”转换为数据类型 int 时转换失败。