• Sorry to be the bearer of bad news, but you can't do that easily at all. Not generically for any stored procedure, anyhow.

    SysDepends / sys.sql_dependencies / sys.sql_expression_dependencies all just show object usage between objects. They show what objects are used, not how they are used.

    One possible route may be for you to create views, and select from the views in your SPs, that would be an OK route for the example you have posted, but might not apply to other SPs that you wish to do the same with. If it does apply, then you can query the meta data of the view, and look in sys.objects and sys.columns to find the relevant information, with the correct ordering.

    If it does not apply - then you might have to actually execute each SP in turn, and use the meta data that comes with the result set(s) to generate the code. Which again isn't ideal.

    Anyhow, hope that gives you some food for thought.

    Atlantis Interactive - SQL Server Tools
    My blog[/url]
    Why I wrote a sql query analyzer clone