Note that there are some explanatory texts on larger screens.

plurals
  1. POSynchronizing SQL Server 2008 database with a proprietory non-SQL database using rowversion
    primarykey
    data
    text
    <p>I am trying to synchronize SQL Server 2008 database with a proprietory third party database. In SQL Server database, I have a SyncId column of type timestamp / rowversion in the tables that I wish to synchronize. But the third party database does not support rowversion or timestamp columns. It only supports a few basic types like string, number, date (stores only date, no time component), boolean, decimal.</p> <p>When I sync for the 1st time, I can probably store the SyncId as a string in the Third Party Database. Later on I will need to retrieve the highest available Sync Id in this third party database. How can I implement my custom comparison logic / sorting logic, so that I can get the highest Sync Id.</p> <p>Further, how do I convert the SyncId string value back to native Sql Server datatype, when sending query or stored procedure parameter to SQL Server?</p> <p>Any other ideas to implement a sync system to download incremental data changes from Sql Server 2008 to the third party database?</p> <p><strong>EDIT:</strong> While retrieving the SyncId from the SQL Server database and converting to string, I am getting an exception. The code is:</p> <pre><code> string sqlSyncId = ""; SqlCommand selectNewAnchorCommand = new SqlCommand(); string newAnchorVariable = "@sync_new_received_anchor"; selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = min_active_rowversion() - 1"; selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.Timestamp); selectNewAnchorCommand.Parameters[newAnchorVariable].Direction = ParameterDirection.Output; selectNewAnchorCommand.Connection = conn; reader = cmd.ExecuteReader(); if (reader.Read()) { do { sqlSyncId = reader["@sync_new_received_anchor"].ToString(); } while (reader.Read()); } Stack Trace: System.IndexOutOfRangeException: @sync_new_received_anchor at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) at System.Data.SqlClient.SqlDataReader.get_Item(String name) </code></pre> <p><strong>EDIT:</strong> I also tried:</p> <pre><code>sqlSyncId = reader["@sync_new_received_anchor"].ToString(); //same error sqlSyncId = reader[0].ToString(); //Works </code></pre> <p>Why I am not able to refer column by name?</p> <p>The value which I am receiving is 101, but in the database table, SyncId column has a different hexadecimal value.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload