简体   繁体   中英

How to compare data between two different columns in two different databases with SQL

Hello I am new to SQL server and I have two databases with two different tables, they are on the same server and I am using Microsoft SQL Server management studio. I need to compare two columns and find which entries do not show up in both columns. Some of these results do match up and I only want to find the differences.

Databases and fields that need querying:

database1, ID number database2, complex ID number

I would just like to find out the entries that do not match up between the two using SQL.

Thanks for your help!

You just need to make sure to reference each piece with the 3 or 4 part name.

Database.Schema.Table when referencing tables and Database.Schema.Table.Column when referencing columns

You can write joins between databases this way and definitely pull data from more than one database.

use linked server see this link

read all, at the end you have the use of sql statements use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM