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.
| Author |
Topic |
|
sandeep1209
Starting Member
6 Posts |
Posted - 2012-03-23 : 14:52:25
|
| Hi guys,I want to crate primary key for 2 columns in the table, as well as i need to create more that 2 columns. I'm trying to create primary key like following way create table usern(userid varchar(20),fname varchar(20),lname varchar(20),village varchar(20) references Towns(tname),phone int,relationship varchar(20)),constraint pl_vilage primary key (fname,lname)-- here i want to create 2 primary key columns those are fname and lname Any one assist me how i need to over come form this problem.Thank'sSandeep.sandeep |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-03-23 : 16:06:18
|
I'm not sure I understand either, but are you asking how to create the primary key constraint outside the table creation? If so, try this: ALTER TABLE dbo.usern ADD CONSTRAINT pl_vilage PRIMARY KEY CLUSTERED (fname,lname) |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-03-23 : 17:22:01
|
quote: Originally posted by X002548 and....what's the problem?
Other than wanting a primary key on a person's name?--Gail ShawSQL Server MVP |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|