Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Unique but not primery key

Author  Topic 

saeidus20
Starting Member

1 Post

Posted - 2011-09-27 : 04:08:29
hi
I'm so new in sql and programming
I just wanted to make a unique value in a table but i dont know how!
i meant i dont want to make a primary key just want a unique value
for example : name(unique)/text/not null)
some one told me i should make it index or some thing

thanks for your help


saeidus20

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-09-27 : 04:14:03
http://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/

--Ranjit
Go to Top of Page

jassi.singh
Posting Yak Master

122 Posts

Posted - 2011-09-27 : 04:19:13
Hi,

You can use Unique Key concept.
Unique Key do following
1)Enforces uniqueness of the column on which they are defined.
2)Creates a non-clustered index on the column.
3)Allows only one NULL Value.

Example "ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE(ColumnName)"


Please mark answer as accepted if it helped you.

Thanks,
Jassi Singh
Go to Top of Page
   

- Advertisement -