-
UNIQUE but not PRIMARY
Hello
for MS SQL 2000 I want to CREATE a Table as follow :
CREATE TABLE [dbo].[Local] (
[id_Local] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar] (100) NOT NULL,
[Info] [nvarchar] (100) NULL
)
id_Local is PrimaryKey autoincrement
but Name must be UNIQUE (not 2 times the same name)
how can script it ?
thank you
-
CREATE UNIQUE INDEX Index1 ON TABLE (Name );
-
Or:
CREATE TABLE [dbo].[Local] (
[id_Local] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar] (100) NOT NULL
UNIQUE NONCLUSTERED,
[Info] [nvarchar] (100) NULL
)
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|