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)
 top n

Author  Topic 

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-10-09 : 05:44:04
hi
if the column(status) any record is null then get top 'n' set rowcount 'nn' else get all the rows
thanxs

krmm

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-09 : 05:51:46
[code]If Exists(select * from table where status is null)
Select Top <n> * from Table
Else
Select * from Table[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-10-09 : 06:17:31
hi
i need to get only the records using set rowcount
and i am getting records which are not null also
i should use proc

krmm
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-09 : 06:20:36
I think you should post proper and accurate sample data and expected output.



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

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-09 : 06:21:18
Why? what's wrong with TOP?

If Exists(select * from table where status is null)
Begin
Set Rowcount <n>
Select * from Table where status is NULL
Set Rowcount 0
End
Else
Select * from Table


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-09 : 07:25:03
quote:
Originally posted by oracle_corrgi

hi
i need to get only the records using set rowcount
and i am getting records which are not null also
i should use proc

krmm


Are you SQL Server?

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-09 : 07:47:34
A better HAL? [:8]

I think he is a man, not a machine.



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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-09 : 08:35:41
quote:
Originally posted by Peso

A better HAL? [:8]

I think he is a man, not a machine.



E 12°55'05.25"
N 56°04'39.16"



I think I dont understand what you said

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-09 : 09:33:59
Madhi,

I think Peso means this http://en.wikipedia.org/wiki/HAL_9000 since you asked OP
quote:
Are you SQL Server?



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-10 : 02:25:55
quote:
Originally posted by khtan

Madhi,

I think Peso means this http://en.wikipedia.org/wiki/HAL_9000 since you asked OP
quote:
Are you SQL Server?



KH
[spoiler]Time is always against us[/spoiler]



Well. Thanks

Madhivanan

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

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-10-10 : 02:45:26
my mind is going...

I can feel it...


elsasoft.org
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-10-10 : 12:39:20
Daisy, Daisy

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -