select sql数据库记录与另一个数据库进行比较 [英] select sql database records compare to another database

查看:89
本文介绍了select sql数据库记录与另一个数据库进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望得到一个查询结果,它将比较2个不同的数据库表,并显示一个表的记录,这些表在字段'name'中没有相同的值

例如table1 / database1字段id,name,address,phone

table1 / database2(相同的SQL本地服务器)字段id,name,date

我想要一个读者(ado) table1 / database1中记录table1 / database2中不存在字段'name'值的记录可以在一个Connection command.text中完成。或者我必须找到值存储它们,例如dataview,然后比较它们?

I want to have the results of a query that will compare 2 different database tables and show the records of one table that don't have the same value in field 'name'
eg table1/database1 fields id,name,address,phone
table1/database2 (same SQL local Server) fields id, name, date
I want to have in a reader (ado) the records of table1/database1 where field 'name' values doesn't exist in table1/database2 can be done in one Connection command.text? or I have to find the values store them eg dataview and then compare them?

推荐答案

只要两个数据库在同一个实例中它直接在SSMS查询中...



从[dbase1] .dbo.table中选择*为t1

加入[dbase2] .dbo.table为t2 on t1.uniqueid = t2.uniqueid
as long as both databases are in the same instance its straight forward in an SSMS query...

select * from [dbase1].dbo.table as t1
join [dbase2].dbo.table as t2 on t1.uniqueid = t2.uniqueid


这篇关于select sql数据库记录与另一个数据库进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆