- table1 (id, name, description, table2_id, ...)
- table2 (id, name, description, type, ...)
Here is a sql sample that make something not expected:
- delete from table1 where id in (select id from table1 where table2_id in (select table_id from table2 where type in (2)));
In table2 there isn't a column called table_id. This sql should not be executed, because we have an error in the sql.
If you execute this sql, it will delete all from table1.
(123 row(s) affected)
SQL-Server SQL Error
We have 2 tables (table1 and table2):
Here is a sql sample that make something not expected:
- table1 (id, name, description, table2_id, ...)
- table2 (id, name, description, type, ...)
Here is a sql sample that make something not expected:
- delete from table1 where id in (select id from table1 where table2_id in (select
tab>
Why it does delete it ? For me it is a bug in sqlserver.
If you execute the last sql only (select table_id from table2 where type in (2)), you will have the following error:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'table_id'.