Showing posts with label Null value in sql server. Show all posts
Showing posts with label Null value in sql server. Show all posts

Monday, May 20, 2013

Insert multiple null values in Unique key index column in sql server

Here is i share Question from my friend : How I insert more than Null value in Unique key field in sql server

Answer  : we can do this using index on all not null value field.

Sample Code :


CREATE TABLE [dbo].[testUnique](
      [col1] [varchar](50) NULL,
      [ID] [int] IDENTITY(1,1) NOT NULL,
) ON [PRIMARY]

CREATE UNIQUE INDEX IX_testUnique ON testUnique(col1)
WHERE col1 IS NOT NULL –-Here we can set any value to which we want to allow multiple value

Insert into testUnique(col1)
values ('a'),(null),(null)



Post From :


If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website