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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Control record count of select

Author  Topic 

sqlpal2009
Yak Posting Veteran

58 Posts

Posted - 2009-08-25 : 09:06:15
Hello All,

I am writing a stored procedure which takes @Rowout as one of the parameter.

My final select displays all the records but now I have to select only the records equals to the @Rowout.

For example

if @Rowout = 10 then
The final Select should show only 10 records.

Something like - SELECT TOP 10 * FROM #table1

Can I do it without using dynamic SQL?

Thanks for any help,

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-08-25 : 09:20:51
SELECT TOP(@RowOut) FROM #Table1

Jim
Go to Top of Page

sqlpal2009
Yak Posting Veteran

58 Posts

Posted - 2009-08-25 : 09:30:52
Thanks Jim.

That worked!

Go to Top of Page
   

- Advertisement -