MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 12th, 2012, 10:44 AM
markyboy17 markyboy17 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 8 markyboy17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 34 sec
Reputation Power: 0
Using ROW_COUNT

Hi Below is the code for my stored procedure


Alter proc [dbo].[InvoiceDisplayTest] (@InvoiceNumber nvarchar(50),@InvoiceDate datetime ,@InvoiceDate1 datetime, @AccountNumber nvarchar(50),@TradingPartnerID nvarchar(50),@Page nvarchar(50),@rownum int OUTPUT)
AS
BEGIN
SELECT * FROM (SELECT InvoiceID,DocumentNumber, convert(char(12),DocumentDate,112) AS DocumentDate,AccountNumber,Supplier,TradingPartnerID,


ROW_NUMBER()OVER(ORDER BY DocumentNumber ASC)AS rowno FROM InvoiceHeader

WHERE (@InvoiceNumber = '' OR DocumentNumber = @InvoiceNumber)
and
(@AccountNumber = '' or AccountNumber = @AccountNumber)
and
(@TradingPartnerID = '' or TradingPartnerID = @TradingPartnerID)
and
(@InvoiceDate = '' or DocumentDate >= @InvoiceDate
and
DocumentDate <=@InvoiceDate1 or @InvoiceDate1 = '')
)As qr
WHERE rowno BETWEEN ((@Page - 1) * 20 + 1)
AND (@Page * 20)

END


My Question is how do I SET my @rownum OUTPUT parameter equal to the total rows for the inner select statement. As the rows for the whole query on counts the ones being displayed. Cant i just use the alias of my ROW_NUMBER() to get the total rows. Or another way.
Looking foward to hearing from you

Mark

Last edited by markyboy17 : September 12th, 2012 at 10:45 AM. Reason: Couldn't see the code

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Using ROW_COUNT

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap