ISZero

  • Is there a function like iszero li isnull where i can check zero

    eg:

    Select isZero(count(*)) from a)




    My Blog: http://dineshasanka.spaces.live.com/

  • No, none built-in that I'm aware of. Based on your example, what checking should this do?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hmpf, too quick...

    Wouldn't this do the job?

    If( select count(*) from authors)>0

     print 'Heureka'

    else

     print 'damn it'

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • thankx frank,

    I have already written a UDF, I wanted to find out whether there is a simple function.

    Anyway I will countine as it is




    My Blog: http://dineshasanka.spaces.live.com/

  • Explain what your magic "isZero()" function is doing.

    Replace 0 with another value it does, like Isnull()? If so, what value should be returned?

    if you want NULL returned, you may use NULLIF:

    NULLIF(Value,0) returns NULL if Value =0, otherwise returns Value.

    If you are trying to suppress values of zero for output, a job for the presentation layer this is !!

  • just my 2 ct

    - Why use a count(*) if your functionality is 'if exists '

    - case yourcol when 0 then ...

                         else yourcol

                         end

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply