Results 1 to 5 of 5

Thread: column options in sql

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    column options in sql

    Hello, I got a question about sql. How can I create a column that values can not repeat, so there can be no identicall values in that column (just like a PK). Well I remember I can do this in MS Access by ticking one of the options, but in the sql I didn't see such an option.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: column options in sql

    You create a unique index on the column.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: column options in sql

    and how to do that in SQL studio please ?

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: column options in sql

    I do it by code.

    Create Unique Index Un_Table1FirstNameLastName on Person
    (FirstName,LastName)
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    Re: column options in sql

    Or you can add a unique key constraint for that column during the creation of the table or alter the table and add the constraint

Posting Permissions

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



Click Here to Expand Forum to Full Width