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)
 Quick rowcount questiion

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2007-11-06 : 09:33:51
I thought I might get a quick answer to this question here:

I'm using a parameter called @Maxrows

I'm using it to set the rowcount, but what I actually want, is if I pass @maxrows = 0 that the rowcount will be ignored, and all the rows will be returned.

Anyone got an idea?

The secret to creativity is knowing how to hide your sources. (Einstein)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-06 : 09:36:08
SET @@ROWCOUNT (@MaxRows)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-06 : 09:36:46
But in SQL Server 2005 you can use dynamic TOP operator like this

SELECT TOP (@MaxRows) *
FROM tSample



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-07 : 01:37:35
and order by will make more sense when using TOP or SET ROWCOUNT

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -