Here is the proc..
I was able to see that the procedure fires in profiler.
but when I try to get a recordcount I get an error msg saying that you can't use recordcount when the resordset is closed. But I take out the temp table it works fine.
I thought maybe it was a permissions thing with tempdb but I have rights...I'm very stumped on this one.
CREATE PROCEDURE rtv_ref_for_dt_range
@start_dt datetime,
@end_dt datetime
AS
BEGIN
DECLARE @total int
CREATE TABLE #tmp(ref_id int not null,
ref_dt datetime not null,
end_dev datetime null,
st_coach datetime null,
elaps_dev int null,
elaps_jc int null)
INSERT INTO #tmp(ref_id, ref_dt, end_dev, st_coach )
SELECT rm.ref_id, rm.ref_dt, jd.end_jd_dt, jc.jc_start_dt
FROM referral_mst rm, job_coaching jc, job_dev jd
WHERE ref_dt >= @start_dt
AND ref_dt <= @end_dt
AND rm.ref_id *= jd.ref_id
AND rm.ref_id *= jc.ref_id
UPDATE #tmp
SET elaps_dev = datediff(day, ref_dt, end_dev),
elaps_jc = datediff(day, end_dev, st_coach)
SELECT @total = COUNT(ref_id) FROM #tmp
SELECT ref_id, CONVERT(CHAR(10),ref_dt,101) as ref_dt,
CONVERT(CHAR(10),end_dev,101) as end_dev,
CONVERT(CHAR(10),st_coach,101) as start_coach,
elaps_dev, elaps_jc, @total as Total
FROM #tmp
END