I'm trying to delete specific rows from various tables by id in my database, and I have too many tables to delete from, for example:
DELETE FROM [Customers]
WHERE [id] = @Id
DELETE FROM [Agents]
WHERE [id] = @Id
DELETE FROM [Policy]
WHERE [id] = @Id
DELETE FROM [Issues]
WHERE [id] = @id
DELETE FROM [Refunds]
WHERE [id] = @Id
EXEC SP_DeleteCustomerRelations @Id
EXEC SP_DeleteAgentComplaints @Id
DELETE FROM [dbo].[Complaints]
WHERE id = @Id
I was wondering if there anyway to enhance the performance of this SQL query?
Or is there anyway to not repeat DELETE? As it takes up to 10 seconds deleting from all these rows from tables.