Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. convert null to zero in sql server 2005

convert null to zero in sql server 2005

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    trilokharry
    wrote on last edited by
    #1

    Nz([fieldname],0) not working Select MAX(UploadID) as id from fshUploadedMaster in above query if no record then returning null but I want to replace null by 0(zero) if returning null thanks

    You get the best out of others when you give the best of yourself.

    C S 2 Replies Last reply
    0
    • T trilokharry

      Nz([fieldname],0) not working Select MAX(UploadID) as id from fshUploadedMaster in above query if no record then returning null but I want to replace null by 0(zero) if returning null thanks

      You get the best out of others when you give the best of yourself.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      select COALESCE(MAX(UploadID), 0) as id from fshUploadedMaster In future please ask SQL questions in the SQL Forum.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      T 1 Reply Last reply
      0
      • T trilokharry

        Nz([fieldname],0) not working Select MAX(UploadID) as id from fshUploadedMaster in above query if no record then returning null but I want to replace null by 0(zero) if returning null thanks

        You get the best out of others when you give the best of yourself.

        S Offline
        S Offline
        samMaster
        wrote on last edited by
        #3

        Use a condition on your query for example like this:

        IF (SELECT MAX(UploadID) AS id FROM fshUploadedMaster) is null
        Select 0 as id
        RETURN

        1 Reply Last reply
        0
        • C Christian Graus

          select COALESCE(MAX(UploadID), 0) as id from fshUploadedMaster In future please ask SQL questions in the SQL Forum.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          T Offline
          T Offline
          trilokharry
          wrote on last edited by
          #4

          ok thanks

          You get the best out of others when you give the best of yourself.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups