This stored procedure is a refinement of work previously done by Sumit Dhingra. It takes a string argument of fields delimited by the 3rd argument character, or a comma if the 3rd argument is missing, and applies each field to the second argument which may be either a SQL statement or, more usually, a stored procedure.
Example:
sp_ForEach “table1,table2,table3″,”sp_spaceused”
Author: Tony Zackin
Download Script:
sp_ForEach.sql
Disclaimer: We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…
Disclaimer Continued
Back to Database Journal Home