troubleshooting Question

Display table difference

Avatar of tselectro
tselectro asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
3 Comments1 Solution187 ViewsLast Modified:
I have to identical tables:
Table1: TagID (Primary key), PlantName,[Object],[Type]
Table2: TagID (Primary key), PlantName,[Object],[Type]

I want to list rows that exist in Table2, but have different data

Ex
Table1
TagID (PK)      PlantName      Object      Type
KRA.Tag1            KP100            Pump1      A
KRA.Tag2            KP100            Pump2      B
KRA.Tag3            KP101            Motor1      B

Table2
TagID (PK)      PlantName      Object      Type
KRA.Tag1            KP100            Pump1      A
KRA.Tag2            KP100            Pump2      C
KRA.Tag3            KP101            Motor2      C
KRA.Tag4            KP102            Motor1      A (exclude this row, does not exist in Table1)

Result I want:
TableName      TagID (PK)      PlantName      Object            Type
Table1            KRA.Tag2            KP100            Pump1            B
Table2            KRA.Tag2            KP100            Pump1            C (diff)
Table1            KRA.Tag3            KP101            Motor1            B
Table2            KRA.Tag3            KP101            Motor2 (diff)      C (diff)


Someone who can help me with the ms sql syntax?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros