Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 make select top 100 a variable

Author  Topic 

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-04-02 : 13:18:34
How do i make select top x a variable in a stored procedure

when i go select top @numberrow ROW_NUMBER() OVER etc

I get an error

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-02 : 13:20:36
are you using sql 2005 or above? then you can use

SELECT TOP (@numberrow) .....

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-04-02 : 13:26:37
sql 2005 -- thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-02 : 13:27:59
try it and see..it should work unless you dont have any other errors

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -