Click here to Skip to main content
15,878,852 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi,
I have a problem with the get a count with my regular fields.
This is my procedure

ALTER proc [dbo].[GetTotalJobs]
@keyword nvarchar(100) =null,
@location nvarchar(100) =null,
@company nvarchar(100) = null,
@title nvarchar(100) =null,
@take int,
@skip int,
@counts int out
as
begin

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON;

WITH CTE AS
(
SELECT   ROW_NUMBER() OVER (ORDER BY id desc ) Sno, Id,Title, CompanyName, LocationName, JobDescription,  DATEDIFF( dd ,CreatedDateTime, GETDATE()) AS CreatedDateTime from Job as c WITH (NOLOCK) 
where  CompanyName like '%'+ @company+'%' or Title like '%'+ @title+'%' or LocationName=@location or JobDescription like '%'+@keyword+'%' or Title like '%'+@keyword+'%'  
group by Id, Title, CompanyName, LocationName, JobDescription, CreatedDateTime
)
select * from CTE WITH (NOLOCK) where Sno between @skip and @take
end


In this procdure I want to return count also as output parameter @counts

Please help me...
Thank you....
Posted

1 solution

SQL
SELECT @counts = COUNT(*) from CTE WITH (NOLOCK) where Sno between @skip and @take
 
Share this answer
 
Comments
NagaRaju Pesarlanka 21-Jun-14 1:30am    
I need total count,
above result @counts return only 10 because I will pass skip and take variables dynamically.
I want total records.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900