Solved

sp_addextendedproc usage

Posted on 1998-09-29
4
576 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: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 70 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

778 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