Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 multiple null in unique column, is it possible?

Author  Topic 

simon780
Starting Member

2 Posts

Posted - 2007-11-20 : 07:24:49
Hi All,



I am having problems with unique contraint, say I have a table called customer
create table customer (
id int identity(1,1) not null,
name nvarchar(50) not null,
id_card_no nvarchar(20) unique,
);

so when I do mutilple null inserts
insert into customer(name, id_card_no)
values("Customer 1", NULL);
insert into customer(name, id_card_no)
values("Customer 2", NULL);

I get an error duplicated keys on the unique column.

In Oracle DB, unique columns are behaved a little different where multiple nulls are allowed in a unique column.

I know there are some tircks that you can do to allow multiple nulls in unique column in sql server(well, pretend to be) like creating a computed column, create a view and an index...



Are there any ways to archieve that in sql sever compact?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-20 : 07:46:09
http://weblogs.sqlteam.com/mladenp/archive/2007/05/17/60209.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

simon780
Starting Member

2 Posts

Posted - 2007-11-20 : 07:55:32
thx for the reply, but the soultions are for sql server, not compact edition
Go to Top of Page
   

- Advertisement -