简体   繁体   English

两个不同的sql服务器之间的数据比较

[英]data compare between two different sql servers

I am currently migrating data from an SQL 2008 R2 to SQL 2014 server and want to check that all data values in the destination server is identical to what is in the source server post migration. 我目前正在将数据从SQL 2008 R2迁移到SQL 2014服务器,并想检查目标服务器中的所有数据值是否与源服务器迁移后的数据相同。 However, the two servers are on different network segments. 但是,两个服务器位于不同的网段上。 What are some ways I can compare data between two different sql servers? 我可以通过什么方法比较两个不同的sql服务器之间的数据?

You can write a hash-function for each table individually. 您可以为每个表分别编写一个哈希函数。 And then just compare the values. 然后只需比较值即可。

Example of a simple implementation of this function for MSSQL: 此功能针对MSSQL的简单实现示例:

SELECT
AVG(CAST(CAST(
            HASHBYTES('MD5', CONCAT(columnn1, column2, column3))
    AS BIGINT) AS FLOAT)) 
FROM simpleTable;

And the same for MySql: 与MySql相同:

SELECT 
AVG(CONV(SUBSTR(MD5(CONCAT(column1, column2, column3)),
             1, 16),
      16, 10))
FROM simpleTable;

It depends on what you need to compare between the two databases, but you should have no problem creating a linked server to get what you need... just be sure to delete the linked server when you're done using it since it does pose a security concern. 这取决于您需要在两个数据库之间进行比较,但是创建链接服务器以获取所需内容应该没有问题...只要确保在使用完链接服务器后就删除它,因为它确实构成了安全问题。 http://learnsqlwithbru.com/2012/01/06/create-linked-server-to-connect-to-another-sql-server-part-i/ http://learnsqlwithbru.com/2012/01/06/create-linked-server-to-connect-to-another-sql-server-part-i/

You could also use Service Broker which is more secure, but a bit more involved as well. 您也可以使用Service Broker,它更安全,但也涉及更多。 https://serverfault.com/questions/98084/can-i-setup-a-link-sql-server-connection-between-servers-on-different-networks https://serverfault.com/questions/98084/can-i-setup-a-link-sql-server-connection-between-servers-on-different-networks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 比较不同服务器中两个相似表之间的数据 - Compare data between two similar tables in different servers 在两台不同机器上的服务器之间复制数据-SQL - copying data between servers on two different machines - SQL 在同一网络的不同PC上的两台SQL服务器之间插入和合并数据 - Insert into and merge of data between two SQL Servers on different PCs on the same network 如何使用SQL比较两个不同数据库中两个不同列之间的数据 - How to compare data between two different columns in two different databases with SQL SQL服务器中两台不同服务器之间的查询表 - Query tables between two different servers in SQL Server Oracle比较两个不同表之间的数据 - Oracle Compare data between two different table 如何比较两个不同的 DBMS 之间的数据? - How to compare data between two different DBMS? SQL如何比较两个表中的数据并获得两个表之间不同的结果 - SQL How to compare data in two tables and get the results that are different between two tables 使用 SSIS 在两个不同的服务器之间传输数据 - Transfer data between two different servers using SSIS 如何比较两个不同提供者的两个不同数据库之间的数据? - How to compare data between two different database of two different providers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM