How can I create a primary key on two columns? I could not find any sensible code sample or description how it should be done. It is clear from MSDN that it is possible but there are no examples.
There is a textbox "Included Columns" in one of the tools for setting primary keys for one column but it does not allow me to enter anything.
Thanks.
Drop table T1
CREATE TABLE [dbo].[T1](
[c1] char(10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[int] NOT NULL,
[nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_T1] PRIMARY KEY CLUSTERED
(
ASC,
ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
one way is as above mentioned , here your pk will be created on column a and b
from Management studio , open the table highlight the multiple colum and press right button. you can select set primary key option
Madhu
|||This is cute, esp the management studio approach. Thank you.
No comments:
Post a Comment