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
 General SQL Server Forums
 New to SQL Server Programming
 return true or false depending on results?

Author  Topic 

crugerenator
Posting Yak Master

126 Posts

Posted - 2010-07-01 : 13:10:12
I was hoping it might be possible to return a result set if a query actually returns results, but if the query returns nothing, is it possible to return false?

Example in psuedo code:

select * from table where id=555

if results > 0, return results, else return false.

Thanks!

X002548
Not Just a Number

15586 Posts

Posted - 2010-07-01 : 13:15:57
[code]
SELECT * FROM table WHERE id=555
IF @@ROWCOUNT = 0
SELECT 'FALSE'
ELSE
SELECT 'TRUE'

[/code]

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

X002548
Not Just a Number

15586 Posts

Posted - 2010-07-01 : 13:17:29
[code]
IF NOT EXISTS(SELECT * FROM table WHERE id=555)
SELECT 'FALSE'
ELSE BEGIN
SELECT * FROM table WHERE id=555; SELECT 'TRUE'; END
[/code]


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

Sachin.Nand

2937 Posts

Posted - 2010-07-01 : 13:24:02
quote:
Originally posted by crugerenator

I was hoping it might be possible to return a result set if a query actually returns results, but if the query returns nothing, is it possible to return false?

Example in psuedo code:

select * from table where id=555

if results > 0, return results, else return false.

Thanks!



Isn't this part supposed to be handled by your BLL if you have a front end.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-07-01 : 13:29:10
quote:
Originally posted by Idera
Isn't this part supposed to be handled by your BLL if you have a front end.



What?

Now we're suppose to make sense of what they post?

sheeessh



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

Sachin.Nand

2937 Posts

Posted - 2010-07-01 : 13:34:56
quote:
Originally posted by X002548

quote:
Originally posted by Idera
Isn't this part supposed to be handled by your BLL if you have a front end.



What?

Now we're suppose to make sense of what they post?

sheeessh



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







lol


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -