We have a VS 2012 .sqlproj database project. We would like to use a scalar valued user defined function to validate one of the table fields in the form of a check constraint.
ALTER TABLE [dbo].[MyTable] ADD CONSTRAINT [CK__MyTable__ColHID] CHECK (dbo.fnValidateHierarchy(ColHID) = 1);
What is the proper way to do this?
We keep experiencing the following error when adding this to the table definition script:
contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [dbo].[fnValidateHierarchy] or [dbo].[Mytable].[dbo]::[fnValidateHierarchy]. c:\...\dbo\Tables\MyTable.sql