Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 changing stored procedure

Author  Topic 

sparrow37
Posting Yak Master

148 Posts

Posted - 2010-03-04 : 06:30:56
Hi all,

I have a stored procedure which selects data from different tables using inner joins and left joins. I want to create a stored procedure based on this stored procedure which will delete records selected by above strored procedure. How can I do this. I want to delete record in one table as well as other tables which are children of it. There are almost 20 tables. I have not created these tables. Someone else created them and these tables have lots of data without parent child checks.

Regards,
Asif Hameed

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-04 : 08:27:58
you need to use a temporary table to dump results of first procedure and then use delete by joining to temporary table to delete the records.

Alternatively you can use below way also if distributed queries are allowed

http://beyondrelational.com/blogs/madhivanan/archive/2007/11/24/select-columns-from-exec-procedure-name-is-this-possible.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -