Id, and Name.
The id is set to the primary key which automatically makes it unique. How would I set the Name to be unique as well?You add a constraint to it. And making it a primary key doesn't make it an identity. That's yet another type of constraint you apply to it. :)|||Ok here is the example
create table tester(a varchar primary key, b varchar(20) unique);
insert into tester values ('1','2');
insert into tester values ('1','2');
insert into tester values ('2','2');
the first insert statement inserts perfectly, and there will be errors with the second and third statement as a is primary key and is unique and second b is unique. so only first statement gets inserted in to the table.|||Ok, so I cannot specify it at the table level. It must be set at time of insert?|||You can check the uniqueness of the field when u try to insert or update the record/data. with data i think the table is useless.
So the concept of uniqueness comes when u r trying to do some transactions with the table right.
Phani...|||You DO specify it at the table level, either when issuing a CREATE or ALTER table statement.|||Is there any way to do it via Enterprise Manager. I've already created the tables.|||Yes. Check out the"Creating a Unique Constraint" article in MSDN (also in Books Online). It provdes step-by-step instructions. You might actually need a Unique Index instead (follow the link in the article for more information).
Terri|||I actually figured it out late last night, this article is exactly what I did.
Thanks for the help guys.
No comments:
Post a Comment