Article View: comp.databases.ms-sqlserver
Article #99Re: create unique index to allow null values
From: Jobi
Date: Wed, 16 Apr 2003 08:47
Date: Wed, 16 Apr 2003 08:47
67 lines
3466 bytes
3466 bytes
It 's not a good idea to allow NULLs on a column that should be part of a
unique index,
because in that case with sqlserver NULL = NULL and therefor there can be
only one.
Check this :
create table T_test1 (col1 int null, col2 varchar(100) NULL)
go
create unique index Ux_T_test1 on T_test1 (col1)
go
insert into T_Test1 (col1, col2) values (1,'test1')
go
insert into T_Test1 (col1, col2) values (2,'test2')
go
insert into T_Test1 (col1, col2) values (3,'test3')
go
-- this one is ok
insert into T_Test1 (col2) values ('Test firts col1-null')
go
-- this one will fail
insert into T_Test1 (col2) values ('Test second col2-null')
go
insert into T_Test1 (col1, col2) values (4,'test4')
go
select * from T_test1
go
drop table T_test1
go
Jobi
"^-^" <mortalnightmare@hotmail.com> wrote in message
news:b7ito9$5kt$1@ctb-nnrp2.saix.net...
> Hi there...
>
> I have a table called dc_weighbridge_MAIN that that has to have an unique
id
> called [ticket] but "ticket" also has to allow null values... so i set the
> ticket field to allow null fields, but to check for duplicate entries I
> created a view called "check_duplicates" wich a form will be based on as
> soon as this function is working.... in the view I added all the records
> but made "ticket" an unique index...
>
> Now when I try to delete or add any records in my table (not even using
the
> view) I get the error: DELETE failed because the following SET options
have
> incorrect settings: 'ARITHABORT'
>
> What's wrong? What I want to achieve is: When my capturer inserts a
record
> that has an "ticket" no there may be no duplicates, and the form should
warn
> you of this when you try to add the record to the sql server, if the
> capturer adds a record that doesn't have a "Ticket" then it will use
another
> form that will be based on another view similar to this one that will be
> based on another "Unique ID" called [Heat_nr]
>
> Plesae help, Thanks alot in advance :)
>
> ^-^
>
>
Technical Details
Message-ID:
<b7j5bv$lbr$1@reader10.wxs.nl>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!newsfeed.wxs.nl!textnews.wxs.nl!not-for-mailReferences:
<b7ito9$5kt$1@ctb-nnrp2.saix.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1135f7,32f0907ad6165bb4 X-Google-Attributes: gid1135f7,public X-Google-Thread: 10b4ec,32f0907ad6165bb4 X-Google-Attributes: gid10b4ec,public X-Google-Thread: 104de1,32f0907ad6165bb4 X-Google-Attributes: gid104de1,public X-Google-Thread: 103584,32f0907ad6165bb4 X-Google-Attributes: gid103584,public X-Google-Thread: ff490,32f0907ad6165bb4 X-Google-Attributes: gidff490,public X-Google-ArrivalTime: 2003-04-16 01:47:07 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!newsfeed.wxs.nl!textnews.wxs.nl!not-for-mail From: "Jobi" <johan.bijnensNo_Spa_M@ugine-alz.arcelor.com> Newsgroups: comp.databases.ms-sqlserver,cz.comp.microsoft.sql,microsoft.public.sqlserver.tools,microsoft.public.za.sql,microsoft.public.za.sql.setup Subject: Re: create unique index to allow null values Date: Wed, 16 Apr 2003 10:47:03 +0200 Organization: Planet Internet Lines: 69 Message-ID: <b7j5bv$lbr$1@reader10.wxs.nl> References: <b7ito9$5kt$1@ctb-nnrp2.saix.net> NNTP-Posting-Host: mail.alz.be X-Trace: reader10.wxs.nl 1050482879 21883 195.95.21.126 (16 Apr 2003 08:47:59 GMT) X-Complaints-To: abuse@planet.nl NNTP-Posting-Date: 16 Apr 2003 08:47:59 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106