June 25, 2003 at 12:11 am
im new in sql. how can i treat two columns of a table as a single primary key?
June 25, 2003 at 12:49 am
Is this what you want?
CREATE TABLE [dbo].[Test] (
[ColA] [int] NOT NULL ,
[ColB] [varchar] (5) NOT NULL ,
[ColC] [money] NOT NULL)
GO
ALTER TABLE [dbo].[Test] WITH NOCHECK ADD
CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED ([ColA],[ColB])
GO
June 25, 2003 at 12:51 am
Oops, should have added the following:
Open Query Analyser.
Change database to your database.
Copy and paste code from previous post.
June 25, 2003 at 3:04 am
quote:
Oops, should have added the following:Open Query Analyser.
Change database to your database.
Copy and paste code from previous post.
tnx it helped me a lot. another question.
what if i have two tables, table1 & table2.
table1 contain columns -- table1id [uniqueID], name [varchar]
table2 contain columns -- table1id [uniqueid], number [int]. table1id is a FK, number is not a unique value.
what will be my PK for table2?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply