About
Pricing
Community
Teams
Start Free Trial
Log in
mssql_v2005
asked on
1/29/2016
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.
Microsoft SQL Server
Databases
Microsoft SQL Server 2008
6
1
Last Comment
Vitor Montalvão
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Lokesh B R
1/29/2016
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mssql_v2005
1/29/2016
ASKER
I don;t want SP, can you share without SP
Vitor Montalvão
1/29/2016
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.
MohitPandit
1/29/2016
If you want to achieve with your single query then you need to CREATE FOREIGN KEY with ON DELETE CASCADE
Best Regards
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
mssql_v2005
1/29/2016
ASKER
This solution is working partially for me.
Vitor Montalvão
1/29/2016
I think you were too fast to accept a solution.
Are the tables related? A delete trigger is an acceptable solution for you?