| Madhivanan's TSQL Blog |
NULL. This is a magical word in Database programming. Here are some interesting facts about NULL in SQL Server.
1 NULL can be defined as absense of value, undefined, or the value which is unknown at this point of time.
2 All datatypes can be defined with NULL constraint
3 Direct usage of artimetic or logical operations on NULL will not work as expected
4 The system functions ISNULL, COALESE and NULLIF are used only to deal with NULL
5 NOT NULL constraint cannot be defined for a computed column until it is also PERSISTED
6 The only datatypes that will interpret NULL differently are rowversion and timestamp Run
2 All datatypes can be defined with NULL constraint
3 Direct usage of artimetic or logical operations on NULL will not work as expected
4 The system functions ISNULL, COALESE and NULLIF are used only to deal with NULL
5 NOT NULL constraint cannot be defined for a computed column until it is also PERSISTED
6 The only datatypes that will interpret NULL differently are rowversion and timestamp Run
this code and see the outputdeclare @rv rowversion , @ts timestamp
select @rv=null, @ts=null
select @rv as rowversion,@ts as timestamp
Output is rowversion timestamp ------------------ ------------------ 0x 0x
7 NULL=NULL will never be true unless SET ANSI_NULLS is OFF
While the first query returns nothing, the second will return 6 --Query 1 set ansi_nulls on select 6 where null=null --Query 2 set ansi_nulls off select 6 where null=null
The condition WHERE col IS NULL will not be affected by the above setting
8 The default datatype of NULL is INT. Refer...(Read whole news on source site)
Output is rowversion timestamp ------------------ ------------------ 0x 0x
7 NULL=NULL will never be true unless SET ANSI_NULLS is OFF
While the first query returns nothing, the second will return 6 --Query 1 set ansi_nulls on select 6 where null=null --Query 2 set ansi_nulls off select 6 where null=null
The condition WHERE col IS NULL will not be affected by the above setting
8 The default datatype of NULL is INT. Refer...(Read whole news on source site)




