Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there's,

I cant able to get input parameter value in sub Query. below is code block in my store procedure
SELECT  *  FROM (SELECT  ROW_NUMBER() OVER (ORDER BY Name asc) as MyRowNumber, *
		
		FROM
		
		tblContactList WHERE friendOfAutoId=@UserAutoId) tblContactList
		
		WHERE
		
		MyRowNumber BETWEEN ( ((@pageNo - 1) * @pageSize )+ 1) AND @pageNo*@pageSize 	


What I have tried:

I am trying to get limited record from databse
Posted
Updated 23-Jan-17 22:50pm

What you need is to name the subquery:
SQL
SELECT  *  FROM (SELECT  ROW_NUMBER() OVER (ORDER BY Name asc) as MyRowNumber, *
                 FROM tblContactList 
                 WHERE friendOfAutoId=@UserAutoId) AS MyDerivedTable
           WHERE MyDerivedTable.MyRowNumber BETWEEN ( ((@pageNo - 1) * @pageSize )+ 1) AND @pageNo*@pageSize
 
Share this answer
 
There is no wrong in this query.

As per the query you want to retrieve the records as per the page number and page size.

So please check whether the input parameter value which you are passing is having the data in that table(tblContactList) or not.
 
Share this answer
 

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