在表中,想把其中2列或多列作为组合主键。
CREATE TABLE [dbo].[T3] ( [col1] NVARCHAR(10) NOT NULL, [col2] NVARCHAR(10) NOT NULL, [col3] NVARCHAR(10) NULL, [col4] NVARCHAR(10) NULL ) GO ALTER TABLE [dbo].[T3] ADD CONSTRAINT [PK__T3__0000000000000003] PRIMARY KEY([col1],[col2]) GOSource Code