assign Null value to a column

  • In a result sql dataset if the value of a particular column is 0 i need to return Null, how do i approach write a query for that

    Let's say i have 3 columns, Dept Name, Dept Division, Dept Count...Let say in my sql query if the Dept Count return 0 i should assign Null to it

  • I would use a case statement to handle this.

  • You could use NULLIF(DeptCount, 0)

    EDIT: Add reference http://msdn.microsoft.com/en-us/library/ms177562%28v=sql.90%29.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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