Tagged Questions
3
votes
2answers
46 views
checksum(newid()) as primary key - what happens if a collision occurs?
Inspecting a rather critical database that is used by some software on my system, I found that one of the tables had a primary key on the column Id, where Id is calculated using checksum(newid()). ...
1
vote
2answers
99 views
Unique Constraint with multiple null columns
I have two tables
PC(Id,EmpName Not NULL, PCName NULL, HostName NULL,.... PhysicalLocation NULL, PCType Not NULL)
PCNetwork(Id, EmpName Not NULL, PCName NULL, HostName ...
4
votes
1answer
79 views
Unexpected Unique Constraint Violation
Given the following CREATE TABLE statement:
CREATE TABLE [dbo].[Unit]
(
[id] SMALLINT NOT NULL IDENTITY(1,1),
[name] VARCHAR(100) NOT NULL,
CONSTRAINT ...
1
vote
2answers
254 views
Best type to use in a composite key when one of the values varies in type
I am building a data store for the content of multiple blog sites which have been scraped. Each of these sites is going to have an entry in a Blog table
BlogId Url ...
16
votes
3answers
4k views
When should I use a unique constraint instead of a unique index?
When I want a column to have distinct values, I can either use a constraint
create table t1(
id int primary key,
code varchar(10) unique NULL
);
go
or I can use a unique index
create table t2(
id ...