Data with onw null Answer - Objective Question  (How many Null values in an unique constraint can be inserted in SQL Server) Question of the Week

Answer – Objective Question (How many Null values in an unique constraint can be inserted in SQL Server)

Interview Questions
Question:- How many NULL value allowed in a column in which Unique constraint is defined in SQL Server?

Options:-

a) 1

b) 2

c) More than 1

Answer :- Option a) 1

In SQL Server, we can Insert only one null value in a column where we have defined the Unique Constraint.

For Example , suppose we made a table test_unique, whose script is given below:-

create table test_unique (id int unique)

Now we insert the following values in it.

insert into test_unique(id) values (1)

insert into test_unique(id) values (2)

insert into test_unique(id) values (NULL)

insert into test_unique(id) values (3)

Here we inserted one null value before inserting 3.

If we see the records in the table , it shows the following data.

Data with onw null Answer - Objective Question  (How many Null values in an unique constraint can be inserted in SQL Server) Question of the Week

Let try to insert another NULL value and see what error it gives.

insert into test_unique(id) values (NULL)

Then it will gives the following error

Unique column error Answer - Objective Question  (How many Null values in an unique constraint can be inserted in SQL Server) Question of the Week

So, In SQL server we can insert only one NULL value in a column where Unique constraint is defined.

DMCA.com

31 thoughts on “Answer – Objective Question (How many Null values in an unique constraint can be inserted in SQL Server)

  1. Pingback: Euro 2020
  2. Pingback: click over here
  3. Pingback: car hire Malta
  4. Pingback: Istanaimpian2
  5. Pingback: their website
  6. Pingback: 인터넷바카라
  7. Pingback: 온라인카지노
  8. Pingback: didi free rides
  9. Pingback: 메이저사이트
  10. Pingback: w88
  11. Pingback: Bassett Caterers
  12. Pingback: Dream Market
  13. Pingback: Drogen
  14. Pingback: w88 casino
  15. Pingback: w88 win

Leave a Reply