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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-28 : 09:50:44
|
| Mike writes "Hi I've got a question, we have a table setup as follows:tableA:aa_idbb_idcc_iddd_idtableB:bb_idcc_iddd_idI'm trying to UPDATE the dd_id column for records in tableA that do not have an entry for bb_id/cc_id/dd_id triplet in tableBI can use a select with not exists to find out which records. (Snagged this off of your site):SELECT ta.aa_id, ta.bb_id, ta.cc_id, ta.dd_id FROM tableA ta WHERE NOT EXISTS (SELECT bb_id, cc_id, dd_id FROM tableB tb WHERE (tb.bb_id = ta.bb_id) AND (tb.cc_id = ta.cc_id) AND (tb.dd_id = ta.dd_id))This query returns 1241 records. When I put this into the FROM clause of an UPDATE statement, I get 4096 records updated.Any insight would be fantastic :)I know fixing the source of the problem is good, but right now we're just focused on data transformation issues" |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-06-28 : 10:46:15
|
| Post the DDL for tables A and B (including keys and foreign relations) and the DML for the update statement, please.Jonathan Boott, MCDBA |
 |
|
|
|
|
|