Check Constraint in Visual Studio 2012 Database Project

  • 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.

    Example:

    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

  • Ignore this topic. There was a type-o which caused the issue.

    Please delete post.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply