locked
Rules in Sql Server 2008 RRS feed

  • Question

  • Hi,

    I am usinig Microsoft Sync framework 2.1 .

    I am applying following rule on my table.

    CREATE RULE STATUS_CD
     AS @col IN ('A', 'I', 'D')

    I am getting below error.

    The target table 'base' of the MERGE
    statement cannot have any enabled rules.  Found rule 'STATUS_CODE'. (Fault Detai
    l is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaul
    ts=true, whose value is:
    System.Data.SqlClient.SqlException: The target table 'base' of the MERGE stateme
    nt cannot have any enabled rules.  Found rule 'STATUS_CODE'.

    The rule plays significant part in the business logic part.After I remove rule the  Sync Framework allows me to Sync.

    Please help me to resolve  below issue.

    Regards,

    Sachin K

     

    Friday, June 10, 2011 9:05 AM

Answers

  • It's because the Sync Framework stored procedures applying changes are using the MERGE statement for doing bulk operations (the SPs with the work Bulk in them) 

    when you provision your scope, you can set SetUseBulkProceduresDefault  to False so it defaults to applying the changes one row at a time without using the MERGE statement.

    • Marked as answer by sakulkarni83 Friday, June 10, 2011 12:18 PM
    Friday, June 10, 2011 10:30 AM

All replies

  • It's because the Sync Framework stored procedures applying changes are using the MERGE statement for doing bulk operations (the SPs with the work Bulk in them) 

    when you provision your scope, you can set SetUseBulkProceduresDefault  to False so it defaults to applying the changes one row at a time without using the MERGE statement.

    • Marked as answer by sakulkarni83 Friday, June 10, 2011 12:18 PM
    Friday, June 10, 2011 10:30 AM
  • Thanks,

    I have used the SetUseBulkProceduresDefault(false) for provisioning  at both client and server side(using WCF).

    I have also added the rule on both the databases.

    Below is the sample code at Server Side.

    SqlSyncScopeProvisioning

    serverConfig = null;

    serverConfig = new SqlSyncScopeProvisioning(serverConn, SqlSyncScopeProvisioningType

    .Template);

     

    serverConfig.SetCreateTableDefault(

    DbSyncCreationOption

    .Skip);

     

    //-- Loads the scope description

    initScopeTableInfo(serverConfig, serverConn);

     

    // Configure the scope and change-tracking infrastructure.

    serverConfig.SetUseBulkProceduresDefault(

    false

    );

    serverConfig.Apply();

    

    //Below is the sample code at Client Side.

    config.PopulateFromScopeDescription(scopeDesc);

     config.SetUseBulkProceduresDefault(false);

     

    config.Apply();

     The Syncronization executes without any errors,butactual syncronization doesnot happen.

    May I know any reason why syncronization must have failed?

    Thanks once again.

    Friday, June 10, 2011 11:22 AM
  • Thanks,

    We have got it done. There was no data to sync.

    Regards,

    Sachin K

     

    Friday, June 10, 2011 12:18 PM