Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: Buddy Ackerman <buddy_nospam@xxxxxxxxxxxxxxxxx>
- Date: Mon, 05 Sep 2005 12:02:25 -0500
It is stupid and you don't understand the issue. This has nothing do with the return of the @@ROWCOUNT before teh rcord set has completed.
sample proc:
create proc test @numrows int output AS SET NOCOUNT ON
select identity(1,1) rownum,* into #tmp from mytable
SET @numrows = @@rowcount
select * from #tmp where rownum between 11 and 20
Typical of a paged return. The issue here has nothing to do with SQL server the issue is that the DataReader interface is not reading the output parameter until after the recordset has been paged through. No reason for it. Stupid.
William (Bill) Vaughn wrote:
Ah, SQL Server is one of the fastest (if not the fastest), most respected and most sophisticated DBMS systems on the planet. This behavior (as stupid as you might think) has been in place since the first implementation of stored procedure OUTPUT parameters. Just because it does not work the way you want it does not make it stupid. The problem is that setting an OUTPUT parameter to a value like @@ROWCOUNT is meaningless. Consider that SQL Server does not know how many rows qualify for the most recent query until all the rows are fetched. Since SQL Server is designed to work with hundreds to thousands of users a second, the data is constantly in flux. As rows are added, changed, removed and moved around in the DBMS, the engine won't (can't) know how many rows will eventually be sent to the client until it has completed the process of retrieving and transmitting the rows to the client. SQL Server does not send any rows to the client until your application actually asks for the rows. This means your application must retrieve each and every row fetched from the server before SQL Server can compute the @@ROWCOUNT. That's one reason why OUTPUT parameters are sent last.
.
- Follow-Ups:
- Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: Pablo Castro [MS]
- Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- References:
- SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: Buddy Ackerman
- Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: William \(Bill\) Vaughn
- Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: Buddy Ackerman
- Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- From: William \(Bill\) Vaughn
- SqlCommand.ExecuteReader does not populate Output Parmeters?
- Prev by Date: Re: Cannot add new row to DataSet
- Next by Date: Re: Oracle 10G Server + ASP.Net + IIS = crash?
- Previous by thread: Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- Next by thread: Re: SqlCommand.ExecuteReader does not populate Output Parmeters?
- Index(es):
Relevant Pages
|