locked
How to Sync data to different database schema? RRS feed

  • Question

  • Hi,

    I am trying to sync data from SQL CE to SQL Enterprise. While moving the data, wanted to move the data to a different database schema. Tried using ObjectSchema to achieve, but not successful.

    Would like to know, is it feasible?

    • Edited by The Elixir Friday, December 28, 2012 4:21 AM
    Friday, December 28, 2012 4:16 AM

Answers

  • alright, I get your issue now.

    the ObjectSchema is only for Sync Fx related objects, not the actual user tables you're synching.

    If you want the user tables on that schema, you will have to pre-create the user tables yourself under the schema that you want.

    • Marked as answer by The Elixir Friday, December 28, 2012 12:30 PM
    Friday, December 28, 2012 9:23 AM

All replies

  • by schema, do you mean different table structures or are you referring to SQL Server schema name?

    Friday, December 28, 2012 5:13 AM
  • Not different table structure but SQL Server schema. For example, dbo.TableX to Sync.TableX. 

    As we don't have SQL schema in CE, will be like 'dbo', but in the destination, wanted to push the tables to 'Sync' schema. I want the tables to be transferred to destination schema, in addition to sync objects and tracking tables. 

    Friday, December 28, 2012 5:17 AM
  • ObjectSchema does that. What issue are you running into? how are you setting the ObjectSchema ?

    Friday, December 28, 2012 5:31 AM
  • // Provisioning in SQL Process DB DbSyncScopeDescription SQLScope = new DbSyncScopeDescription("MyScope"); DbSyncTableDescription ceT1Description = SqlCeSyncDescriptionBuilder.GetDescriptionForTable("t1", SQLCeConn); ceT1Description.LocalName = "t1"; SQLScope.Tables.Add(ceT1Description); DbSyncTableDescription ceT2Description = SqlCeSyncDescriptionBuilder.GetDescriptionForTable("t2", SQLCeConn); ceT2Description.LocalName = "t2"; SQLScope.Tables.Add(ceT2Description); SqlSyncScopeProvisioning SQLProv = new SqlSyncScopeProvisioning(SQLServerConn, SQLScope); SQLProv.SetCreateTableDefault(DbSyncCreationOption.CreateOrUseExisting); SQLProv.ObjectPrefix = "Sync"; SQLProv.ObjectSchema = "MSSync"; //MSSync is SQL Server schema and already available in target database SQLProv.Apply(); // Provisioning in CE DB DbSyncScopeDescription ceScope = new DbSyncScopeDescription("MyScope"); DbSyncTableDescription T1Description = SqlCeSyncDescriptionBuilder.GetDescriptionForTable("t1", SQLCeConn); T1Description.LocalName = "t1"; ceScope.Tables.Add(T1Description); DbSyncTableDescription T2Description = SqlCeSyncDescriptionBuilder.GetDescriptionForTable("t2", SQLCeConn); T2Description.LocalName = "t2"; ceScope.Tables.Add(T2Description); SqlCeSyncScopeProvisioning CEProv = new SqlCeSyncScopeProvisioning(SQLCeConn, ceScope); CEProv.ObjectPrefix = "Sync"; //Since CE will not have schema, it is ignored here. CEProv.Apply(); CESyncOrchestrator syncOrchestrator; SqlCeSyncProvider CeProvider = new SqlCeSyncProvider("MyScope", SQLCeConn, "Sync"); SqlSyncProvider SQLProvider = new SqlSyncProvider("MyScope", SQLServerConn, "Sync", "MSSync"); syncOrchestrator = new CESyncOrchestrator(CeProvider, SQLProvider); SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();

    Please find the code block and revert. Tables T1 and T2 are expected to move to MSSync schema of sql server, which is not happening.
    Friday, December 28, 2012 8:53 AM
  • alright, I get your issue now.

    the ObjectSchema is only for Sync Fx related objects, not the actual user tables you're synching.

    If you want the user tables on that schema, you will have to pre-create the user tables yourself under the schema that you want.

    • Marked as answer by The Elixir Friday, December 28, 2012 12:30 PM
    Friday, December 28, 2012 9:23 AM