Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Second primay key in a table


Message #1 by "Ninh" <ninhht@y...> on Tue, 30 Jan 2001 17:34:14 -0000
Or as simple as:

ALTER TABLE dbo.Table1 
	ADD PRIMARY KEY CLUSTERED (ID,Name) 
            ON [PRIMARY]
 


-----Original Message-----
From: Imar Spaanjaars [mailto:Imar@S...]
Sent: Tuesday, January 30, 2001 10:50 AM
To: sql language
Subject: [sql_language] Re: Second primay key in a table


Here is a short example that defines two fields as the primary keys of a
table:

CREATE TABLE [dbo].[Table1] (
         [ID] [int] IDENTITY (1, 1) NOT NULL ,
         [Name] [char] (10) NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Table1] WITH NOCHECK ADD
         CONSTRAINT [PK_Table1] PRIMARY KEY  CLUSTERED
         (
                 [ID],
                 [Name]
         )  ON [PRIMARY]
GO


HtH

Imar

P.S. You could create the table in EM, than script your table to a SQL file 
to see how the SQL should look.

At 05:34 PM 1/30/2001 +0000, you wrote:
>I can create 2 primary key in a table with EM, but when I used SQL
>language it doesn't work. I'll be grateful of any help.



  Return to Index