USE OF ISNULL IN SQL SERVER 2005

1. Syntax is : ISNULL ( check_expression , replacement_value )

2. ISNULL : Replaces NULL with the specified replacement value.

3. SELECT ISNULL(NULL,’Pawan’) — Will give output Pawan means the replacement string

4. SELECT ISNULL(‘one’ , ‘Pawan’) — if the expression is not null it will return the original string

5. SELECT ISNULL(1,’2′) — Expression can be int also , in this case it will retrun the original value ie.1

6. ISNULL is helpful when you are contatenating strings. Eg.

7. SELECT (NULL + ‘PAWAN’) — This will give you the output NULL
SELECT (ISNULL(NULL,”) + ‘Pawan’) — This will give you the proper output as ‘Pawan’

8. SELECT ISNULL(NULL,NULL) — This will return NULL

Happy Programming.

Pawan Kumar
Pawankkmr@hotmail.com

Advertisements