anchor.diff:      end
     end
   %>
  -
  -IF EXISTS
  -  ( SELECT *
  -    FROM dbo.sysobjects
  -    WHERE id = OBJECT_ID(N'<%= data_module.sql.schema %>.spCheckConstraints') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  -  DROP PROCEDURE <%= data_module.sql.schema %>.spCheckConstraints
  -GO
   
   CREATE PROCEDURE <%= data_module.sql.schema %>.spCheckConstraints
   AS
  
positive.code: %><%
      object_type.sql.function_constraints.each do |constraint|
  %>
  IF  EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'<%= constraint.qualified_constraint_name %>') AND parent_object_id = OBJECT_ID(N'<%= object_type.sql.qualified_table_name %>'))
    ALTER TABLE <%= object_type.sql.qualified_table_name %> DROP CONSTRAINT <%= constraint.constraint_name %>
  GO
  IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'<%= data_module.sql.schema %>.<%= s(object_type.name) %>_<%= s(constraint.name) %>') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
    DROP FUNCTION <%= data_module.sql.schema %>.<%= s(object_type.name) %>_<%= s(constraint.name) %>
  GO
  CREATE FUNCTION <%= data_module.sql.schema %>.<%= s(object_type.name) %>_<%= s(constraint.name) %>
  (
  <%= constraint.parameters.collect{|parameter_name| a = object_type.attribute_by_name(parameter_name); "  @#{a.sql.column_name} #{a.sql.sql_type}"}.join(",\n") %>
  
negative.code: %><%
        object_type.sql.triggers.each do |trigger|
  %>
  CREATE TRIGGER <%= trigger.qualified_trigger_name %> ON <%= object_type.sql.qualified_table_name %>
  <%
    if trigger.after && !trigger.after.empty?
  