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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Check Constraint

Author  Topic 

aidmondo
Starting Member

23 Posts

Posted - 2012-05-14 : 06:47:21
Create table Date
(
StartDate datetime not null,
EndDate datetime not null
)
How do i use the CHECK Constraint to make the StartDate < EndDate

aidmondo

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-14 : 06:57:13
[code]
DO below one

Create table Date
(
StartDate datetime not null ,
EndDate datetime not null
)


alter table Date add check (StartDate < EndDate)[/code]

Vijay is here to learn something from you guys.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-14 : 06:59:53
quote:
Originally posted by aidmondo

Create table Date
(
StartDate datetime not null,
EndDate datetime not null
)
How do i use the CHECK Constraint to make the StartDate < EndDate

aidmondo

ALTER TABLE [Date] ADD CONSTRAINT chkDates CHECK (StartDate  < EndDate );
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-14 : 22:44:13
quote:
Originally posted by vijays3


DO below one

Create table Date
(
StartDate datetime not null ,
EndDate datetime not null
)


alter table Date add check (StartDate < EndDate)


Vijay is here to learn something from you guys.


did you test this at all?
Posted syntax is wrong!

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -