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)
 basic SP help

Author  Topic 

GoDaddy
Yak Posting Veteran

64 Posts

Posted - 2009-08-06 : 13:53:29
I'm looking at a more elegant way to do the following :

CREATE SP
@top int = NULL
AS
if @top is not null
BEGIN
select TOP @top * FROM Employees
END
else
select * FROM Employees

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-06 : 13:59:30
One option:

declare @rc int
set @rc = isNull(@top, 0)

set rowcount @rc
select <colList> from employees order by <something>
set rowcount 0

You could also look int "server side paging" techniques

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -