Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Question of the month Apr 2012 - Why does SQL Server allow only one NULL value on unique constraint?

Apr 11 2012 12:00AM by Madhivanan   

Run the following code

	declare @t table(i int unique)
	insert into @t 
	select 1 union all
	select null union all
	select null 

You will get the following error

Msg 2627, Level 14, State 1, Line 3
Violation of UNIQUE KEY constraint 'UQ__#A989971__3BD019979D26A3BB'. Cannot insert duplicate key in object 'dbo.@t'. The duplicate key value is ().
The statement has been terminated.

But other RDBMSs like ORACLE, MySQL, etc will allow multiple NULL values on a column defined as Unique key. It is because that NULL values cannot be equal to each other

Why does SQL Server allow only one NULL value on a column that has unique constraint?

Tags: t-sql, sql_server, sqlserver, tsql, question,


Madhivanan
3 · 40% · 12936
11
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Question of the month Apr 2012 - Why does SQL Server allow only one NULL value on unique constraint?" rated 5 out of 5 by 11 readers
Question of the month Apr 2012 - Why does SQL Server allow only one NULL value on unique constraint? , 5.0 out of 5 based on 11 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]