SQL サーバーで 1 つのクエリを実行していますが、「データ型 varchar を数値に変換中にエラーが発生しました」というエラーが表示されます。データベースにクエリを実行しているクエリを以下で見つけてください。
SELECT Limit = (Case isnull(PR009000.COVERAGE ,null)
When isnull('UM',null) then
(Case
When 'SPLIT' = 'CSL' then ( select UMLimitTypeDes from CASeleUMLimitType where UMCoverageTypeCd =( 'SPLIT' )
and UMLimitTypeCd=(Select top 1 USAMNT02 From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
and StateCd= (select top 1 RATESTE from PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1) )
When 'SPLIT' = 'SL' then (select UMLimitTypeDes from CASeleUMLimitType where UMCoverageTypeCd=( 'SPLIT' )
and UMLimitTypeCd=(Select top 1 USAMNT02 From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
and StateCd=(select top 1 RATESTE from PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1))
When 'SPLIT' = 'BI' then (select UMLimitTypeDes from CASeleUMLimitType where UMCoverageTypeCd=( 'SPLIT' )
and UMLimitTypeCd =cast((Select top 1 USAMNT03 From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' ) AS varchar(100))
and StateCd =cast((select top 1 RATESTE from PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1) AS varchar(100)))
When 'SPLIT' = 'N' or 'SPLIT' = 'SPLIT' then ( select top 1 isnull(UMLimitTypeDes,null) from CASeleUMLimitType where UMCoverageTypeCd=( 'SPLIT' )
and UMLimitTypeCd=(Select top 1 isnull(USAMNT03,null) From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
and StateCd=(select top 1 isnull(RATESTE,null) from PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1) )
When 'SPLIT' = 'PD' then (
select isnull(UMLimitTypeDes,null) from CASeleUMLimitType where UMCoverageTypeCd=( 'SPLIT' )
and UMLimitTypeCd=(Select top 1 isnull(USAMNT04,null) From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
and StateCd=(select top 1 isnull(RATESTE,null) from PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1))
End )
When isnull('UN',null) then
(Case
When 'SPLIT' = 'CSL' then
(Select isnull(USAMNT02,null) From PR009000 Where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and coverage='UN')
When 'SPLIT' = 'BI' then
(Select isnull(USAMNT03,null) From PR009000 Where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and INSLINE = 'CA' and coverage='UN')
When 'SPLIT' = 'N' then
(Select isnull(USAMNT03,null) From PR009000 Where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and INSLINE = 'CA' and coverage='UN')
End )
When 'DOC-MP' then
(Select USCDE14 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'DOC-UM' then
(Select USIND06 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'DOC-UN' then
(Select USIND05 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'DOCUMP' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='DOCUMP')
When 'DOCUNP' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='DOCUNP')
When 'DTHBEN' then
(Select USAMNT03 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='DTHBEN')
When 'HIRE' then
(Select USAMNT05 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'HIREUM' then
(Select USIND09 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'HIREUN' then
(Select USIND12 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'LIAB' then
(Select USAMNT05 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'MEDPAY' then
(Select USCDE02 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'NONUM' then
(Select USCDE08 From PR006000 where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA' )
When 'SOUND' then
(Select USAMNT03 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='SOUND')
When 'TRLCMP' then
(Select USAMNT03 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='TRLCMP')
When 'TRLCOL' then
(Select USAMNT03 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='TRLCOL')
When 'TRLSP' then
(Select USAMNT03 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='TRLSP')
When 'UMPD' then
(Select USAMNT01 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='UMPD')
When 'REG-UM' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='REG-UM')
When 'REG-UN' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='REG-UN')
When 'REG-L' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='REG-L')
When 'REG-MP' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='REG-MP')
When 'REG-PIP' then
(Select USAMNT04 From PR009000 where SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1 and insline = 'CA' and coverage='REG-PIP')
Else
( Select '-1' )
End )
FROM PR009000 WHERE SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1
ここで PR009000 は、そのようなデータを持つテーブルです。
select * FROM PR009000 WHERE SYMBOL='CPP' AND POLNUM=0001148 AND MODULE=00 AND LOC=00 AND MCO=05 AND PCO=05 AND UNTRECNUM=1
これはクエリで使用される別のテーブルです
Select * From PR006000 Where Symbol= 'CPP' and POLNUM = '0001148' and MODULE = '0 ' and MCO = '05' and LOC= '00' and INSLINE = 'CA'
どこに問題があり、これに対する解決策を教えてください。