home
training courses
why choose us?
solutions
support
company
LearnItFirst User Forum
Welcome Guest
Search
|
New Posts
|
Members
|
Log In
|
Register
SQL Server Forum - LearnItFirst.com
»
Transact-SQL Programming
»
Stored Procedures, Triggers, & Functions
»
CURSOR RESULTS (IN A STORED PROC)
CURSOR RESULTS (IN A STORED PROC)
Options
Previous Topic
·
Next Topic
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
Back to top
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.
Back to top
Users browsing this topic
Guest
Forum Jump
SQL Server Database Administration
- General SQL Database Question & Answer
- Backup, Recovery and Disaster Recovery
- SQL Server Security
- Integration Services (SSIS) and DTS
Transact-SQL Programming
- DML (SELECT, INSERT, UPDATE, DELETE) Questions
- Stored Procedures, Triggers, & Functions
SQL Server Scripts, Code Samples and SSMS Custom Reports
- All SQL Server Versions
- SQL Server 2005/2008
- SQL Server Management Studio Custom Reports
Customer Service
- Video Requests
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.
SQL Server 2005 DBA Training Videos
SQL Server 2008 DBA Training Videos
Watch this topic
RSS Feed
Email this topic
Print this topic
Threaded
Normal