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 |
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2012-01-23 : 22:18:58
|
My table design as following,CREATE TABLE [dbo].[myGred]( [idx] [int] IDENTITY(1,1) NOT NULL, [code] [varchar](50) NOT NULL, [gred] [varchar](100) NOT NULL, [stDte] [datetime] NOT NULL, [edDte] [datetime] NOT NULL, CONSTRAINT [PK_myGred] PRIMARY KEY CLUSTERED ( [idx] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [myGred_UQ1] UNIQUE NONCLUSTERED ( [code] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]stDte is a startDte. edDte is a endDteMy question as following,1. How to create check constraint on stDte? The condition is stDte <= endDteIf possible, please guide me to create that check constraint |
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2012-01-24 : 01:08:42
|
http://msdn.microsoft.com/en-us/library/ms188258.aspxALTER TABLE myGredADD CONSTRAINT chkDates CHECK (stDte <= endDte );GO |
 |
|
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2012-01-24 : 03:51:22
|
tq Mr LoztInSpace |
 |
|
|
|
|
|
|