Hi David,
Take also look at SQL-DMO. For example,
Re: SQL Scripts Message #
708081.
>Hi Sergey,
>
>Thanks. This will do the trick. I guess this is the only way then to perform the equivalent of macro substitution.
>
>Also, Bob Archer sent me a very helpful reply regarding an article on the sp_MSForEach SP's, which I didn't know about. It looks like they contain the majority of the code that I was intending to write from scratch, and they use EXECUTE in the manner you suggested.
>
>
--sb--