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)
 select statement

Author  Topic 

GoDaddy
Yak Posting Veteran

64 Posts

Posted - 2009-04-21 : 10:36:46
I want in my select to show a function return value if the return value is greater that a value.

ex:

Select colA, colb, function(@someparam)
from etc

to show the function(@someparam) only if it return a string greater than 0 for example.

is that possible ?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-21 : 10:42:39
What do you want to show if it is less than zero?

Madhivanan

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

GoDaddy
Yak Posting Veteran

64 Posts

Posted - 2009-04-21 : 11:04:06
empty string probably
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-21 : 11:07:19
Try this..

Select colA, colb, case when function(@someparam) > 0 then function(@someparam) else '' end
from etc
Go to Top of Page

whitefang
Enterprise-Level Plonker Who's Not Wrong

272 Posts

Posted - 2009-04-21 : 11:08:42
quote:
Originally posted by vijayisonly

Try this..

Select colA, colb, case when function(@someparam) > 0 then function(@someparam) else '' end
from etc



The function could just return '' instead.
Go to Top of Page
   

- Advertisement -