Sunday, February 19, 2012

Index and constraint on uniqueidentifier field

Hi,
I have made an index on a uniqueidentifier field.
Now I don't want duplicate values.
Should I set the "is unique" property to true or add an contraints on this
field?
Thanks!if you use a default of newid() you are guaranteed uniqueness, or the
chances of getting a duplicate is miniscule.
You can add a unique index to this column,
create unique index test on tablename(uniquecolumnname)
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Arjen" <boah123@.hotmail.com> wrote in message
news:dcq6a6$v4u$1@.news5.zwoll1.ov.home.nl...
> Hi,
> I have made an index on a uniqueidentifier field.
> Now I don't want duplicate values.
> Should I set the "is unique" property to true or add an contraints on this
> field?
> Thanks!
>|||Let's say that I don't generate an id with newid().
I create an unique index and I add one id two times. Do I receive an error
when adding it for the second time?
Thanks!
"Hilary Cotter" <hilary.cotter@.gmail.com> schreef in bericht
news:euqubdBmFHA.3304@.tk2msftngp13.phx.gbl...
> if you use a default of newid() you are guaranteed uniqueness, or the
> chances of getting a duplicate is miniscule.
> You can add a unique index to this column,
> create unique index test on tablename(uniquecolumnname)
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Arjen" <boah123@.hotmail.com> wrote in message
> news:dcq6a6$v4u$1@.news5.zwoll1.ov.home.nl...
>|||You bet!
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Arjen" <boah123@.hotmail.com> wrote in message
news:dcq9h6$tot$1@.news6.zwoll1.ov.home.nl...
> Let's say that I don't generate an id with newid().
> I create an unique index and I add one id two times. Do I receive an error
> when adding it for the second time?
> Thanks!
>
>
> "Hilary Cotter" <hilary.cotter@.gmail.com> schreef in bericht
> news:euqubdBmFHA.3304@.tk2msftngp13.phx.gbl...
>|||If you don't mind letting the server assign new ids sequentially, then
re-define the column as an identity.
"Arjen" <boah123@.hotmail.com> wrote in message
news:dcq6a6$v4u$1@.news5.zwoll1.ov.home.nl...
> Hi,
> I have made an index on a uniqueidentifier field.
> Now I don't want duplicate values.
> Should I set the "is unique" property to true or add an contraints on this
> field?
> Thanks!
>

No comments:

Post a Comment