Click here to Skip to main content
12,829,669 members (45,063 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-Server
Hi friends.
Is Unique key accept null value. In my application it does not accept multiple null value.but from i studied it accept null for unique column.suppose it accept, how can i modify my unique column table for accepting null value

Advance Thanks
Posted 3-Nov-12 22:58pm
Updated 3-Nov-12 23:02pm
Abhishek Pant 4-Nov-12 4:27am
Will you eloborate what type of unique key you used a primary key or unique key.... in case of unique key 1 null value is accepted for every row and column. while in case of primary key no null values are accepted.if you built a primary key then||alter table <table name> drop constraint constraint_name Primary key(column_name)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Logically, any key which is allowed to contain non duplicate (unique) values is a unique key, NULL is a permissible value in SQL Server , so it can have NULL for a single time just like any other value.

But as per standards, there is no such rule that only ONE NULL is allowed. So, with SQL Server you are stuck with just one time NULL value.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If you mean on a primary key column, then no - you can't have null primary keys.

If you mean a unique index on a nullable column, well...not really a good is possible.

Have a look here:[^]
Sandeep Mewara 4-Nov-12 4:24am
Yeah, but there is a limitation/issue with SQL Server with multiple NULL values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100