Monday, 7 July 2014

SQL : How to display Null when 0 (Data type is int)


There can be occasions you need to select out NULL values when an integer data type brings 0. Here is the quick fix,


Select CASE WHEN [empNum] = 0 THEN NULL ELSE CONVERT(VARCHAR(30),[empNum]) END AS empNum
From ...