[thelist] MSSQL Cursor help
Joshua Olson
joshua at waetech.com
Thu Aug 18 15:19:33 CDT 2005
> -----Original Message-----
> From: Brian Cummiskey
> Sent: Tuesday, August 16, 2005 4:58 PM
>
> Hey all, I'm pulling my hair out on this one.
> declare DNCList cursor for
> SELECT job AS 'joblist'
> FROM jobs
> WHERE --etc
>
> OPEN DNCList
> FETCH NEXT FROM DNCList into @joblist
> while @@fetch_status = 0
> begin
> set @query = 'SELECT * FROM ' + @joblist --etc
> end
>
> exec(@query)
>
> FETCH NEXT FROM DNCList into @joblist
> CLOSE DNCList
> DEALLOCATE DNCList
Try:
declare DNCList cursor for
SELECT job AS 'joblist'
FROM jobs
WHERE --etc
OPEN DNCList
FETCH NEXT FROM DNCList into @joblist
while @@fetch_status = 0
begin
set @query = 'SELECT * FROM ' + @joblist --etc
exec(@query)
FETCH NEXT FROM DNCList into @joblist
end
CLOSE DNCList
DEALLOCATE DNCList
<><><><><><><><><><>
Joshua L. Olson
WAE Tech Inc.
http://www.waetech.com/
Phone: 706.210.0168
Fax: 413.812.4864
Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/
More information about the thelist
mailing list