阿罗哈,
我有一个存储过程,它在3个不同的列中查找值。
ALTER PROCEDURE [dbo].[sp_CLAIMS_QUERY_FAC_]
@sPLAN varchar(5),
@sTYPE varchar(3),
@nVALUE varchar(10) ,
@begDOS date,
@endDOS date
AS
BEGIN
SET NOCOUNT ON;
-- QUERY BASED ON CAID.............................................................
IF @sPLAN = 'CAID'
IF @sTYPE = 'MBR'
BEGIN
SELECT DISTINCT
PLN, DH, PT, PROVIDER, TAX, PROV_NAME, MEMGRP, MEMSUB, MBR_NAME,
POS, AUDNBR, CLM_ADJ, LN_NR, RCVD_DT, FIRST_DOS, LAST_DOS, CPT, CPT_MOD,
UNITS, DIAG1, PAID_DT, REV_CDE, BILL_TYPE, FIN_LGL_NBR, PAR, OCC_CD5,
AMT_CLAIMED, AMT_DISALLOW, AMT_DISCOUNT, AMT_DEDUCT, AMT_COPAY, AMT_PAID,
DEN_CDE, DSLW_CDE, DENY_DESC, DSLW_DESC, ADJ_RSN_DESC, REV_DESC, POS_DESC,
CPT_DESC, DIAG_DESC
FROM v_QI_CLAIMS_FAC
WHERE (@nVALUE = (MEME_HICN) AND (FIRST_DOS BETWEEN @begDOS AND @endDOS) AND PLN = 'CAID')
OR (@nVALUE = (MEMSUB) AND (FIRST_DOS BETWEEN @begDOS AND @endDOS) AND PLN = 'CAID')
OR (@nVALUE = (MEME_CK) AND (FIRST_DOS BETWEEN @begDOS AND @endDOS) AND PLN = 'CAID')
ORDER BY AUDNBR, LN_NR, CLM_ADJ
END
memsub和meme_hicn中的数据是表中的varchar,meme_ck是一个int。查询为memsub和meme_ck提取数据,但是当值来自meme_hicn时,我收到错误:
转换varchar值时转换失败' 558901488A'到数据类型int(其中数据值为' 558901488A'。
看起来它将meme_hicn解释为int,但它应该是一个varchar。
我尝试了各种各样的选项,演员等,但似乎没有任何效果。