srodgers45
asked on
Make "NULL" returns in a column into a set value
I want to make "NULL" values in a column into a set value such as whenever there is "NULL" it will equal "99" in SQL Server. Is that possible?
Thanks in advance....
The column name is "PCRServer.dbo.PCR.STATUS"
Thanks in advance....
The column name is "PCRServer.dbo.PCR.STATUS"
ASKER
Thanks for the help, very much appreciated....
Hello srodgers45
We can use COALESCE(yourcolumnName,'9 9') to replace the NULL values of the table to value 99 while getting the output.
SELECT othercolumns, COALESCE(PCRServer.dbo.PCR .STATUS,'9 9') PCR_Status
From yourTable
Read more about the command from - https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql
Vaibhav
We can use COALESCE(yourcolumnName,'9
SELECT othercolumns, COALESCE(PCRServer.dbo.PCR
From yourTable
Read more about the command from - https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql
Vaibhav
FYI, ISNULL and COALESCE are not exactly the same:
ISNULL ( check_expression , replacement_value ) -- useful for a single value/replacement and is T-SQL specific syntax
COALESCE ( expression [ ,...n ] ) -- can evaluate one or more values and then a replacement and is SQL Standard syntax
https://docs.microsoft.com/en-us/sql/t-sql/functions/isnull-transact-sql
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql
ISNULL ( check_expression , replacement_value ) -- useful for a single value/replacement and is T-SQL specific syntax
COALESCE ( expression [ ,...n ] ) -- can evaluate one or more values and then a replacement and is SQL Standard syntax
https://docs.microsoft.com/en-us/sql/t-sql/functions/isnull-transact-sql
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql
Hello PortletPaul
Yes you are correct but in this specific case they are same. Here we are just checking single column value.
Vaibhav
Yes you are correct but in this specific case they are same. Here we are just checking single column value.
Vaibhav
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
So in your case ...
SELECT isnull(PCRServer.dbo.PCR.S