|
Home > Archive > Microsoft SQL Server forum > November 2005 > multi-field primary key
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
multi-field primary key
|
|
| sql guy123 2005-11-28, 1:23 pm |
| I have a table (table1) that has a bunch of fields....
[field1]
[field2]
[field3]
[field4]
[field5]
None of these fields are unique, but if I combine them, then they are
unique.
I know there is a way to make multi-field primary keys, but when I try
I get an that field1 is not unique, which I already know,
How can I make a multi-field primary key?
thanks
| |
| David Portas 2005-11-28, 1:23 pm |
| ALTER TABLE table1
ADD CONSTRAINT pk_table1 PRIMARY KEY (col1, col2, col3, col4, col5) ;
Tip: "column" and "row" are the terms usually preferred over "field"
and "record" when discussing SQL databases. Some people will argue that
there are quite different concepts attached to the different names and
that the distinction is a very important one. Others use the names
interchangeably without worrying to much about the formal definitions.
Still, you won't be called wrong if you stick with the terms "column"
and "row". :-)
Hope this helps.
--
David Portas
SQL Server MVP
--
| |
| sql guy123 2005-11-28, 8:25 pm |
| thanks, I try it
|
|
|
|
|