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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql date check

Author  Topic 

jamsman
Starting Member

3 Posts

Posted - 2005-02-25 : 11:43:28
Im trying to create a table with three date attributes, the problem is that i need to check that the second date is after the first date can i do this with a check constraint if so how if not how???????

Thank you

X002548
Not Just a Number

15586 Posts

Posted - 2005-02-25 : 12:05:44
[code]
USE Northwind
GO

SET NOCOUNT ON
CREATE TABLE myTable99 (
Col1 int IDENTITY(1,1)
, Col2 Datetime DEFAULT Getdate()
, Col3 datetime
, CHECK (Col2 < Col3))
GO

INSERT INTO myTable99(Col3)
SELECT '1/1/2006'
GO

SELECT * FROM myTable99
GO

INSERT INTO myTable99(Col3)
SELECT '1/1/2004'
GO

SET NOCOUNT OFF
DROP TABLE myTable99
GO

[/code]


Brett

8-)
Go to Top of Page
   

- Advertisement -