how to IF NULL then value = 0

  • how do i do this from link server

    if null then value = 0

    ------------------------

    UPDATE [pitable].[dbo].[allpi]

    SET val32=

    (SELECT     *

    FROM         OPENQUERY(pcnh, 'SELECT value as vh3   FROM picomp  WHERE time = date(''*'') AND tag = ''HQ0MP001MX''

    '))

    ----------------------------------------

     

    thnks

    ilan

  •  

    UPDATE [pitable].[dbo].[allpi]

    SET val32= isnull(

    (SELECT     *

    FROM         OPENQUERY(pcnh, 'SELECT value as vh3   FROM picomp  WHERE time = date(''*'') AND tag = ''HQ0MP001MX''

    ')),0)

    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

  • Update ...

    Set val32 = ISNULL((Select vh3 FROM OPENQUERY(....)),0)

    Should work. Works fine if the inner select is all local. I don't have a handy linked server to test on.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 1 through 2 (of 2 total)

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