SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Check Constraint
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aidmondo
Starting Member

Ghana
23 Posts

Posted - 05/14/2012 :  06:47:21  Show Profile  Reply with Quote
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

India
311 Posts

Posted - 05/14/2012 :  06:57:13  Show Profile  Reply with Quote

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.
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 05/14/2012 :  06:59:53  Show Profile  Reply with Quote
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

India
47099 Posts

Posted - 05/14/2012 :  22:44:13  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000