LearnItFirst User Forum

New SQL Server 2008 DBA Course
Welcome Guest Search | New Posts | Members | Log In | Register

CURSOR RESULTS (IN A STORED PROC) Options
NIRVANA
Posted: Monday, February 23, 2009 5:10:39 PM
Rank: Newbie

Joined: 2/23/2009
Posts: 1
Points: 3
Where do you live?: MELBUORNE
i HAVE A QUERY THAT INCORPORATES A CURSOR.

NOW THE QUERY LOOKS SOMETHING LIKE

SELECT * FROM EMP WHERE BUSINESS = ???

I THEN PUT THIS INTO A CURSOR AS I DO SOME ADDITIONAL CODING AND TRANSLATIONS. I HAVE NO PROBLEM WRITING THE CURSOR OR GETTING THE RESULTS. WHAT I NEED TO DO IS HAVE THE RESULTS FROM THE CURSOR BE DISPLAYED LIKE A NORMAL QUERY OR STORED PROC (WITHOUT CURSOR) SO I CAN THEN ACCESS THE DATA DIRECTLY AND NOT THRU A SELECT STATEMENT ON A CUSTOM TABLE

AT THE MOMENT I HAVE THE RESULTS INSERTED INTO A TABLE AND I THEN TO SELECT ON THE TABLE TO GET THE RESULTS.

BUT WHAT I WOULD LIKE IS TO RUN THE STORED-PROC (FROM VB OR REPORT SERVER) AND RETRIEVE THE RESULTS DIRECTLY FROM THE PROC AND NOT SOME CUSTOM TABLE I HAVE INSERTED THE DATA INTO. I HAVE TRIED ASSIGNING THE DATA TO VARIABLES AND THEN PRINTING THE VARIABLES USING PRINT BUT I CANNOT REFERENCE THE DATA VIA VISUAL BASIC OR REPORT SERVER AS THE RECORDSET APPEARS BLANK. THE REASON I NEED THIS IS REPORTS CAN BE RUN AT THE SAME TIME BY MULTIPLE USERS HENCE DATA COULD AND PROB WOULD BE CORRUPTED.

I AM SURE THIS CAN BE DONE JUST DONT KNOW HOW.

CHEERS



Scott Whigham
Posted: Wednesday, February 25, 2009 10:41:09 AM


Rank: Super Mod

Joined: 3/20/2006
Posts: 460
Points: 1,002
Where do you live?: Dallas, TX
The problem with doing what you ask is that, for each iteration of the cursor, you would return a separate result set (if I understand your question). If you wrote a cursor and had it do a SELECT statement on each iteration, you would return multiple results and that's not likely what you want. Inserting into a table and selecting from the table is an acceptable way.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.