Results 1 to 4 of 4

Thread: UNIQUE but not PRIMARY

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    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

  2. #2
    Join Date
    Oct 2006
    Posts
    5
    CREATE UNIQUE INDEX Index1 ON TABLE (Name );

  3. #3
    Join Date
    Sep 2002
    Posts
    5,938
    Or:

    CREATE TABLE [dbo].[Local] (
    [id_Local] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar] (100) NOT NULL
    UNIQUE NONCLUSTERED,
    [Info] [nvarchar] (100) NULL
    )

  4. #4
    Join Date
    Apr 2006
    Posts
    178
    thank you

    i try at once

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •