Wednesday, March 7, 2012

Execute same statement for each value in result set

Hi everyone,

My brain refuses to remember the (undocumented?) stored procedure I'm
thinking of. It takes at least two parameters: a sql statement to
execute, and a table name (or something of that nature).

Then, for each value in the table, it executes the sql statement and
passes the value as a parameter.

Can anybody refresh my memory? The functionality may be slighly
different than described, but the principle is the same. Thanks very
much...

-JoeNow that I think about it, rather than a table name, I believe one of
the parameters may be statement that returns a 1 column resultset, as
it would probably make more sense.|||xp_execresultset

More info here:
http://www.rac4sql.net/xp_execresultset.asp

The usual warnings apply about the use of undocumented features.

--
David Portas
SQL Server MVP
--|||Indeed... Thanks a lot...

No comments:

Post a Comment