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
 Database Design and Application Architecture
 Non-future dates, constraint on type

Author  Topic 

srouse
Starting Member

7 Posts

Posted - 2010-02-12 : 11:22:18
I need a domain that will not allow future dates. i.e. <= getdate()
I've previously accomplished this with a rule, but since Microsoft is deprecating rules and recommending check constraints I need to change my ways.

Is it possible to put a check constraint on a user defined type?

I know I can add column constraints per table, but I would rather apply it to the datatype if possible.

Thanks

Scott

dportas
Yak Posting Veteran

53 Posts

Posted - 2010-02-12 : 17:15:05
SQL User Defined Types are obsolete and deprecated. You could use a CLR UDT but I don't see much point just to add a <=GETDATE() constraint. My suggestion would be to use CHECK constraints on your columns. Or why not validate the value in a stored procedure.
Go to Top of Page
   

- Advertisement -