Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cakewalkr7
Starting Member
11 Posts |
Posted - 2010-03-09 : 10:54:33
|
| I have two tables that join on a peopleid field. Each table also has a state value. I need to get a list of records that join on the peopleid field where the state fields don't match. I'm not sure how to construct this. Just to clarify the table definitions would be like...Table1PeopleId intState char(2)Table2PeopleId intState char(2) |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-03-09 : 11:28:22
|
Maybe just?SELECT t1.[peopleId] , t1.[state] , t2.[state]FROM table1 t1 JOIN table2 t2 ON t2.[peopleId] = t1.[peopleID]WHERE t1.[state] <> t2.[state] OR (t1.[state] IS NULL AND t2.[state] IS NOT NULL) OR (t1.[state] IS NOT NULL AND t2.[state] IS NULL) Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
cakewalkr7
Starting Member
11 Posts |
Posted - 2010-03-09 : 13:28:23
|
| Hmmm, I don't know why I didn't think of that:) Thanks! |
 |
|
|
|
|
|