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 2000 Forums
 SQL Server Development (2000)
 Another TOP question...

Author  Topic 

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-01-02 : 02:08:11
Is there any way to do a dynamic TOP count without resorting to dynamic SQL (or dynamically creating stored procedures, etc). Something like:

select top @iRowCount login_name from users where...


Thanks
-b

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-01-02 : 02:16:20
hmmm, you could have this answered if you only spent 20 seconds searching the site and the forums...

Use

SET @@Rowcount = @myval
SELECT * from Table
SET @@Rowcount = 0



Damian
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-01-02 : 09:26:00
set rowcount @myval
select * from Table
set rowcount 0


.


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.

Edited by - nr on 01/02/2002 09:26:51
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-01-02 : 09:28:23
oooops

That's embarassing

Yet another reason to look up syntax in books online

Damian
Go to Top of Page
   

- Advertisement -