Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-01-10 : 08:52:18
|
| Can someone show me a code example of using a cursor to loop through the result of a Select Statement in a Stored Proc?thanks |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-01-10 : 08:56:20
|
Sorry, it is TOTALLY against our nature to do such a thing (well, if you absolutely MUST, try this:http://www.sqlteam.com/item.asp?ItemID=553and search the forums for "cursor", you'll find tons of examples, and tons of set-based non-cursor solutions you SHOULD be using instead) |
 |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2002-01-10 : 09:16:49
|
| Maybe you could tell us what you're trying to do and give us some sample data. Essentially, cursors are a last resort because of their performance issues. Maybe we could help you find a set based solution that performs better.Mike "A program is a device used to convert data into error messages." |
 |
|
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-01-11 : 13:24:39
|
| well I thought it would be more efficient to loop through a RS from within the SP and parse my data and then send it out to the caller. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-01-11 : 13:31:43
|
| Do you have to loop through a recordset row by row?If so it probably indicates a design problem.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-11 : 15:11:55
|
quote: parse my data and then send it out to the caller.
Hmmm... What sort of parsing are you doing? What is the calling application? You might find that there are some very handy features in ADO which would handle your needs efficeintly. For example, the .GetRows and .GetString methods of the ADO Recordset object can rapidly retrieve info and so some degree, parse it.--------------------------------There's a new General in town... |
 |
|
|
|
|
|