SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL server 2012 pagination with total rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aoriju
Posting Yak Master

India
156 Posts

Posted - 07/26/2013 :  10:28:09  Show Profile  Reply with Quote
Hi all

My table contains 1000 records,
i need to know the total record count with the below paging query

SELECT EmpName,Place
FROM EmplyeeDetails ORDER BY Place
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;

How to get

James K
Flowing Fount of Yak Knowledge

3761 Posts

Posted - 07/26/2013 :  10:32:52  Show Profile  Reply with Quote
If you want it with each record,
SELECT EmpName,Place, count(*) over() as TotalRecords
FROM EmplyeeDetails ORDER BY Place
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22773 Posts

Posted - 07/28/2013 :  10:35:18  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
or

declare @total int
set @total=(select count(*) from EmplyeeDetails)

SELECT EmpName,Place, @total as total_records
FROM EmplyeeDetails ORDER BY Place
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000