Results 1 to 4 of 4

Thread: [SQL Server]forcing each value in a column to be unique without making it an identity

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    [SQL Server]forcing each value in a column to be unique without making it an identity

    I'm using whatever version of SQL Server that comes with VS 05. I think it's 2003. I can't seem to find a way to either make a column an identity but keep it type char and thus not have it increment or make a column accept only values that aren't already in that column. It seems like something someone would want to do pretty often (like if they wanted unique UserID's and Usernames) so there has to be a way to do it, right?
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [SQL Server]forcing each value in a column to be unique without making it an identity

    Just set it as Unique.

    If you want to do it using SQL statements see here. You can also do it easily in the table design within Enterprise Manager (S.S. 2000), and presumably Management Studio (S.S. 2005).

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [SQL Server]forcing each value in a column to be unique without making it an identity

    apparently VS 05 did something to my .mdf file to make SQL management studio not be able to open it. It worked before but now it doesn't I'm reinstalling Management studio. Too bad VS doesn't have ANY WAY TO CHANGE THE COLUMN SPECS TO UNIQUE! Why would they even leave that out? There's really no reason
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [SQL Server]forcing each value in a column to be unique without making it an identity

    well that didn't work but I'm redoing a lot of my program because I shouldn't be converting non-unique fields back to their unique primary key ID fields anywhere anyway cuz they should be able to double up :P
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

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