Sunday, March 11, 2007

Getting the value of Constraint

Recently I was asked by my colleague to return tha actual value of CHECK constaint that he has defined on the table.
I think it can be usefull for some reports that we've done on the database.
Tested on SQL Server 2000(SP3a) and SQL Server 2005(SP2a)

CREATE TABLE Test
(
col INT,
coldatetime DATETIME
)

ALTER TABLE Test
ADD CONSTRAINT coldatetime_check
CHECK ( coldatetime > '20070101')

SELECT text FROM syscomments
WHERE id =OBJECT_ID('coldatetime_check')

1 comment:

aiya said...
This comment has been removed by a blog administrator.