Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Goodafternoon guys,

How can i query and (display or change) it into a dash if the data in the specific column is null using case?


Thank You, any suggestions and opinion, will be so much appreciated!.
Posted

Hi,

you can make use of ISNULL function of SQL. which will replace the DBNull value with your custom text or value (based on the datatype).
SQL
--Example.
SELECT ISNULL(ColumnName, 'Your Text') AS 'Value' FROM TabelName

you can refer ISNULL[^] for more information.

hope it helps
 
Share this answer
 
Try this one

SELECT p.ProductId,
                   p.ProductName,
                   CASE
                        WHEN p.[Description] IS NULL THEN '-'
                        ELSE p.[Description]
                   END AS 'Description'
            FROM   Products p
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900