Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sp_addextendedproc usage

Posted on 1998-09-29
4
Medium Priority
?
599 Views
Last Modified: 2008-03-04
While using SQL Trace on an application, I noticed the following code:
sp_cursorfetch 95226679,2,0,1

sp_cursorfetch is defined as follows:
exec sp_addextendedproc 'sp_cursorfetch','(server internal)'

Could someone explain what is happening here?
0
Comment
Question by:vd
  • 2
4 Comments
 

Author Comment

by:vd
ID: 1090326
Adjusted points to 70
0
 
LVL 7

Expert Comment

by:Victor Spiridonov
ID: 1090327
There are two ways ODBC driver can 'request' data from SQL server can send data to your application - either by executing straight select and sending all the data at once -in this case you will see 'SELECT....' statement.
In the secon case it builds cursor on the server side and uses sp_cursorfetch to fetch data in chunks.
0
 

Author Comment

by:vd
ID: 1090328
What would be the reason to use this method? Also, what
are the parameters being used, such as 952266979 ?
0
 
LVL 2

Accepted Solution

by:
martyn_bannister earned 210 total points
ID: 1090329
vd,

sp_cursorfetch appears to be a compiled system stored procedure, written by the boys and girls at Microsoft.

As such, we can't work out what parameters it takes, although I would hazard a guess that 952266979 is an id (probably of the cursor itself).

A cursor will naturally be used when MS-SQL Server is building a result set in answer to a SELECT statement. It is essentially the area of memory on the server where the rows are stored before being sent to the client. The sp_cursorfetch is the procedure that sends each row.

Instead of writing a simple SELECT statement on the client, it is also possible to directly create and fetch rows from a CURSOR. This is normally done when you want to act on each row coming back from the database individually, rather than receive them as a block of rows which can only be processed after the last one has arrived. This situation normally arises when what you want to do something horrendously complicated with each row, but don't want to store them in a temporary table and work from that.

See "DECLARE CURSOR" in Transact SQL help for further details.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question