как создать ключ состоящий из нескольких полей

Komandante77
Дата: 19.01.2009 18:29:12
как создать ключ состоящий из нескольких полей
типа того что на картинке ниже синего цвета
Komandante77
Дата: 19.01.2009 18:29:33
Паганель
Дата: 19.01.2009 18:34:32
create table t(id1 int, id2 int, name varchar(10), constraint pk_t primary key(id1, id2))
insert into t(id1, id2, name)
select 1, 2, '1_2' union all
select 10, 20, '10_20' union all
select 10, 200, '10_200'
go
insert into t(id1, id2, name) values(10, 20, '10_20')
go
select * from t
go
drop table t
go


(3 row(s) affected)
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'pk_t'. Cannot insert duplicate key in object 'dbo.t'.
The statement has been terminated.
id1         id2         name
----------- ----------- ----------
1           2           1_2
10          20          10_20
10          200         10_200

(3 row(s) affected)
_djХомяГ
Дата: 19.01.2009 18:35:51
cм Alter Table
alter table <таблица> add contarint <имя> primary key <список колонок>