December 7, 2007 at 12:09 pm
I know you can use UDFs in Check Constraints but could you use an Inline Table valued Function in a CHeck constraint like:
(Column in (select * from fnTableData))
December 7, 2007 at 1:35 pm
December 7, 2007 at 1:42 pm
So far I've gotten this:
Subqueries are not supported in CHECK constraints
December 7, 2007 at 1:58 pm
I would say that your answer is NO then. Check Constraints do not support the use of inline table valued functions.
December 7, 2007 at 2:15 pm
John,
I would say that your answer of NO is probably correct. Although I am no SQL master so maybe there is a way around it...
December 7, 2007 at 3:18 pm
In this case, not by using a CHECK Constraint (that I know of). You are limited to using a trigger to validate your data or add the checking logic to your INSERT/UPDATE stored procedures if you are using SPs exclusively to handle INSERT/UPDATEs.
Why not use a foreign key relation to your other table? Wouldn't that serve the same purpose?
December 7, 2007 at 7:08 pm
AVB (12/7/2007)
John,I would say that your answer of NO is probably correct. Although I am no SQL master so maybe there is a way around it...
Simple scalar function which returns 1 if parameter is in the range, 0 if it's not.
Constraint will look like this:
dbo.CheckFunction (CheckedColumn) = 1
_____________
Code for TallyGenerator
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply