Solved

sp_addextendedproc usage

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now