How to use NULL or empty string in SQL
I would like to know how to use NULL and an empty string at the same time in a WHERE
clause in SQL Server. I need to find records that have either null values or an empty string. Thanks.
Select *
From Table
Where (col is null or col = '')
Or
Select *
From Table
Where IsNull(col, '') = ''
If you need it in SELECT section can use like this.
SELECT ct.ID,
ISNULL(NULLIF(ct.LaunchDate, ''), null) [LaunchDate]
FROM [dbo].[CustomerTable] ct
You can replace the null
with your substitution value.
You can simply do this:
SELECT *
FROM yourTable
WHERE yourColumn IS NULL OR yourColumn = ''
SELECT *
FROM TableName
WHERE columnNAme IS NULL OR
LTRIM(RTRIM(columnName)) = ''