No. In SQL server we can insert only one NULL value to column which has UNIQUE KEY constraint.
Example:
CREATE TABLE SamepleUnique ( Id INT PRIMARY KEY, Name varchar(20) UNIQUE ) INSERT INTO SamepleUnique VALUES(1,'Ram') INSERT INTO SamepleUnique VALUES(2,'Krish') INSERT INTO SamepleUnique VALUES(3,Null) INSERT INTO SamepleUnique VALUES(4,Null) --Error as Violation of UNIQUE KEY constraint 'UQ__SamepleU__737584F603317E3D'. Cannot insert duplicate key in object 'dbo.SamepleUnique'. --The statement has been terminated. |
Output: |
0 Comments:
Post a Comment