...

View Full Version : Variable as criteria



N_R_D
07-28-2006, 06:48 PM
SELECT B.CALACT, B.CALDAT, B.CALTIM, B.CALOPR
INTO #uniquecalls2MONTHS
FROM #UNIQUELOANSTOGETREPEATS AS A
JOIN CONTACT.DBO.PHNLOG AS B ON (A.CALACT1=B.CALACT)
WHERE B.CALACT >0
AND B.CALDAT BETWEEN @startDate AND @60DayEnd
AND B.CALTYP in (903)
AND B.CALLOG IN ('C','T')
GROUP BY B.CALACT, B.CALDAT, B.CALTIM, B.CALOPR

I would like to have


declare @superVar varchar(50)
select @superVar = 'CALTYP in (903)'

SELECT B.CALACT, B.CALDAT, B.CALTIM, B.CALOPR
INTO #uniquecalls2MONTHS
FROM #UNIQUELOANSTOGETREPEATS AS A
JOIN CONTACT.DBO.PHNLOG AS B ON (A.CALACT1=B.CALACT)
WHERE B.CALACT >0
AND B.CALDAT BETWEEN @startDate AND @60DayEnd
AND @superVar
AND B.CALLOG IN ('C','T')
GROUP BY B.CALACT, B.CALDAT, B.CALTIM, B.CALOPR

Where

AND B.CALTYP in (903)

is

AND @superVar

How would I go about coding that?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum