In SQL , Instead of NULL values , I need to show user defined values

66 Views Asked by At

I don't know how to do this, Please anyone help me on this?

3

There are 3 best solutions below

1
On

You can do this on a select to modify null field to return something else

select COALESCE(t.[MyField],'This Field is NULL') from MyTable t

Link to functions for various rdbms : http://www.w3schools.com/sql/sql_isnull.asp

MS SQL Server for instance has ISNULL

0
On

If it is about changing the value in the database, try...

update mytable set myNullableAttribute = 'a specific value' where myNullableAttribute is null
0
On

Hi @Kindnesscounts123YT ,

Please have a look below example for your question.

In employee table ,before using ISNULL function it will show below Output

Query :

select * from emp

Output :

empno empname salary gender
1 Pradeep 1500 Male
2 Ajay 2500 NULL

When I use ISNULL function , i will get below output

Query :

select
empno, empname, salary, ISNULL(gender,'hi') as Gender from emp

Output:

empno empname salary Gender
1 Pradeep 1500 Male
2 Ajay 2500 hi