christer99
IS-IT--Management
- Dec 3, 2001
- 247
I am trying to compare a string using the IN statement using a dynamic variable, such as WHERE (dbo.POLICY.STATUS IN (@v_statact))
DECLARE
@v_statact VARCHAR(90),
@v_actlostcd VARCHAR(80)
set @v_statact = (SELECT CURSTCODES
FROM dbo.ProgramConf)
set @v_statact=replace(@v_statact, ' ', ' ')
set @v_statact=''''+replace(@v_statact, ' ', ''', ''')+''''
SELECT dbo.INS.REC, dbo.INS.NAME, dbo.INS.ATTN, @v_statact as bbb
FROM dbo.POLICY RIGHT OUTER JOIN
dbo.INS ON LEFT(dbo.POLICY.POL_IDX, 7) = dbo.INS.REC LEFT OUTER JOIN
dbo.AccountInfo ON dbo.INS.REC = dbo.AccountInfo.ACCREC
WHERE (dbo.POLICY.STATUS IN (@v_statact))
GROUP BY dbo.INS.REC, dbo.INS.NAME, dbo.INS.ATTn
DECLARE
@v_statact VARCHAR(90),
@v_actlostcd VARCHAR(80)
set @v_statact = (SELECT CURSTCODES
FROM dbo.ProgramConf)
set @v_statact=replace(@v_statact, ' ', ' ')
set @v_statact=''''+replace(@v_statact, ' ', ''', ''')+''''
SELECT dbo.INS.REC, dbo.INS.NAME, dbo.INS.ATTN, @v_statact as bbb
FROM dbo.POLICY RIGHT OUTER JOIN
dbo.INS ON LEFT(dbo.POLICY.POL_IDX, 7) = dbo.INS.REC LEFT OUTER JOIN
dbo.AccountInfo ON dbo.INS.REC = dbo.AccountInfo.ACCREC
WHERE (dbo.POLICY.STATUS IN (@v_statact))
GROUP BY dbo.INS.REC, dbo.INS.NAME, dbo.INS.ATTn