Link to home
Start Free TrialLog in
Avatar of mssql_v2005

asked on

SQL query+SQL Server

I want to delete rows from 3 tables based on ID column. Can you please share logic/or query to delete rows.

ex: 3 tables with the name of A,B,C

ID column exist on all 3 tables. I will pass ID as input parameter and want to delete rows from 3 tables from single query.
Avatar of Lokesh B R
Lokesh B R
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mssql_v2005


I don;t want SP, can you share without SP
The DELETE command only accepts a table or a view name so I don't think you can't do it from a single statement.
If you want to achieve with your single query then you need to CREATE FOREIGN KEY with ON DELETE CASCADE

Best Regards
This solution is working partially for me.
I think you were too fast to accept a solution.
Are the tables related? A delete trigger is an acceptable solution for you?