Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,525 of 19,505    |
|    Jens Riedel to All    |
|    Re: Problem with DELETE statement    |
|    09 Jun 09 15:26:06    |
      From: JensRie@gmx.de              Hi Ed,              > Jens, can you describe the actual concepts behind "a" and "b" in       > your situation? I suspect that Joe is right, but that it would       > be easier to understand when applied to a specific example.              table "a" and "b" have no specific constraint or similar.       In the current case we fill several tables during a data import.       If we want repeat the import we have to delete all data that has been       stored during the first run.       Most of the tables have a field which refers to a specific import batch,       but some miss this field. But there are some relations where one can       find out which data belongs to the import by joining them with a table       containing the import ID.       So we use something like              delete from table_a       where relation_id in        (select some_id from table_b where import_id = 25)              Because it is allowed that table_a contains data which has no relation       to table_b there is no constraint or cascade-delete construct we could use.       The only thing I'm concerned about is that the execution of the       statement could slow down the complete DB if the sub-query delivers       thousands ore more IDs for the Where-In-condition.              Regards       Jens              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca