I am an sql that was created in Microsoft Sequel Server,and I am cutting and pasting that into Crystal Reports 10 via the add command function. My information comes up blank, mainly because of a declare formula/function at the beginning of the sql. When I take out this declare function at the top and bottom of the sql, it retrieves data. How do I fix this where it will run in Crystal with this variable? thx !

DECLARE @COUNTY VARCHAR(50)
DECLARE curCOUNTY CURSOR FOR SELECT COUN_CO_NAME FROM MW_CO ORDER BY COUN_CO_NAME
OPEN curCOUNTY
FETCH curCOUNTY INTO @COUNTY
WHILE @@FETCH_STATUS <> -1
BEGIN

SELECT
CODE.CODE_SHORT_DESC as region
,@COUNTY as county
,INV.INTI_INTAKE_ID
,per.PERS_FIRST_NAME AS HH_FIRST_NAME
,per.PERS_LAST_NAME AS HH_LAST_NAME
,rpt.INTR_INTAKE_DT AS INTAKE_DATE
,SCR.INTS_ASSIGN_DATE AS ASSIGN_DATE
,nar.mindate AS NAR_DATE
,inv.INTI_FIND_SUBMIT_DATE
,inv.INTI_FIND_PEND_DATE
,inv.INTI_FIND_APP_DATE
,case when inv.INTI_FIND_APP_DATE is not null then '' else 'Y' END AS STILLOPEN
,CASE WHEN inv.INTI_FIND_APP_DATE IS NULL
THEN
DATEDIFF(D,RPT.INTR_INTAKE_DT,'1/31/2013')
ELSE
DATEDIFF(D,RPT.INTR_INTAKE_DT,inv.INTI_FIND_APP_DA TE) end AS OPENDAYS
--
,CASE WHEN DATEDIFF(MINUTE,SCR.INTS_ASSIGN_DATE,nar.mindate)< =1440 THEN 'Y' ELSE '' END
--
,CASE WHEN DATEDIFF(MINUTE,RPT.INTR_INTAKE_DT,nar.mindate)<=1 440 THEN 'Y' ELSE '' END
from MW_INT_INVESTIGATION inv
--JOIN USING INTAKE ID
join MW_INT_SCREEN scr
on scr.INTS_INTAKE_ID=inv.INTI_INTAKE_ID
--JOIN USING INTAKE ID
join MW_INT_REPORT rpt
on rpt.INTR_INTAKE_ID=INV.INTI_INTAKE_ID
--JOIN COUNTY TABLE TO GET THE MATCHING COUNTY NAME AND REGION CODE
JOIN MW_CO CO
ON INV.INTI_CO=CO.COUN_CO
--JOIN THE CODE TABLE TO GET THE REGION DESCRIPTION
join MW_CODE_TABLE CODE
on CO.COUN_REGION=CODE.CODE_TABLE_VALUE AND CODE.CODE_TABLE_NAME='REGION'
--GET THE RELATED PERSON DATA USING INTAKE ID
join dbo.MW_INT_RPT_PERS RPER
ON INV.INTI_INTAKE_ID=RPER.INRP_INTAKE_ID
--AND THE PERSON ID
JOIN dbo.MW_PERS PER
ON RPER.INRP_C_PERS_ID=PER.PERS_PERS_ID
--JOIN THE NARRATIVE LIST, FILTERED
join
(select
MIN(n.narr_date)as mindate
,N.NARR_SYSTEM_ID
FROM MW_NARRATIVE N
where
n.NARR_SYSTEM_TYPE='I'
AND
n.NARR_SUB_SYSTEM_TYPE='I'
AND
(n.NARR_CONTACT_TYPE=260 OR n.NARR_CONTACT_TYPE=280)
group by N.narr_system_id)nar
on nar.narr_system_id=rpt.Intr_intake_id
where
--RESULTS MUST BE WITH NO FINDINGS, OR FINDINGS IN THE REPORT PERIOD
(INV.INTI_FIND_APP_DATE IS NULL or INV.INTI_FIND_APP_DATE BETWEEN '1/1/2013' AND '1/31/2013')
--AND INTAKES HAPPENIGN BEFORE TEH END OF THE REPORT PERIOD
and
rpt.INTR_INTAKE_DT <= '1/31/13'
--AND INTAKES WHICH HAVE A SETTING ID
and
rpt.intr_ane_ooh_setting_id<>''
--AND INTAKES FOR TYPE C - CHILD
and
rpt.INTR_ANE_TYPE='C'
and
INRP_C_PERS_HH_STAT_CD='PRIM'
and
CO.COUN_CO_NAME=@COUNTY
FETCH curCOUNTY INTO @COUNTY
END
close curCOUNTY
deallocate curCOUNTY