Solved

sp_addextendedproc usage

Posted on 1998-09-29
4
578 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

830 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