can I execute a stored proc within sp_MSforeach...

  • Hello all.

    I run a bunch of DBCC tasks this weekend using sp_MSforeach... and it work great. I have a quick question, though. Can I execute a store proc within any of those?

    I have quite a few stored procs for maintenance and they run quite well, but of course I have to call each one everytime (well, not me personally!! a DTS) is any way I can incorporate sp_MSforeach... to run this stored procs?  or any other command?

    something like:

    exec sp_MSforeachtable @command1 ="print '?' TRUNCATE TABLE ('?')"

    or

    exec sp_MSforeachtable @command1 ="print '?' exec usp_updateZipCode ('?')"

     

    Thank you

  • I was trying the same thing a while back and ended up using a SP that I found on this site -

     

    http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=900

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply