I know this is very simple, but how do I do this in plain SQL?
A:
Primary key constraint?
CREATE TABLE [dbo].[Table1](
[Id1] [int] NOT NULL,
[Id2] [int] NOT NULL,
[AnotherColumn] [varchar](256) NOT NULL,
CONSTRAINT [PK_Id1_Id2] PRIMARY KEY CLUSTERED
(
[Id1] ASC,
[Id2] ASC
)
joerage
2009-12-03 19:52:42
+2
A:
For a unique constraint during table creation:
CREATE TABLE T1 (
Col1 int NOT NULL,
Col2 int NOT NULL,
UNIQUE (Col1, Col2)
)
After table creation:
ALTER TABLE T1 ADD UNIQUE (Col1, Col2)
Mark Byers
2009-12-03 19:54:29
Perfect. Thank you.
Byron Whitlock
2009-12-03 20:18:36
A:
Are you talking about check constraints?
alter table MyTable add constraint CC_Dates check (FromDate < ToDate)
UserControl
2009-12-03 19:56:25