[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?
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).
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! :mad: :mad: :mad: Why would they even leave that out? There's really no reason :mad:
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