Click here to Skip to main content
15,886,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
rewrite below incorrect statement in two ways using isnull and coalesce
select * from Test_Table where Test_ID=null


What I have tried:

rewrite below incorrect statement in two ways using isnull and coalesce
select * from Test_Table where Test_ID=null
Posted
Updated 7-Jul-18 5:09am

SQL
SELECT    TOP 10 *
FROM      Google
WHERE    (NULL, Coalesce) IN SearchTerms
 
Share this answer
 
Not clear what your question is. But here an example on how to use COALESCE and ISNULL function.

SQL
--if first column/Test_ID is null, use value from second column which is ''
SELECT    *
FROM      Test_Table 
WHERE    COALESCE(Test_ID, '') = ''

--if Test_ID is null, return ''
SELECT    *
FROM      Test_Table 
WHERE    ISNULL(Test_ID,'') = ''

Here you can find out more about the mentioned functions.
COALESCE (Transact-SQL) | Microsoft Docs[^]
Deciding between COALESCE and ISNULL in SQL Server[^]
 
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