[英]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.