Get column names/types returned from a stored procedure

后端 未结 3 952
粉色の甜心
粉色の甜心 2020-12-15 22:01

Is there a way via metadata (Information_Schema, perhaps?) to get a list of the columns a sproc will return? I\'m trying to automate some code generation and that would help

3条回答
  •  猫巷女王i
    2020-12-15 22:18

    My way of doing this: Edit the stored procedure to have an INTO clause:

    Change

    Select * from tablename
    

    to

    Select * INTO _tablename FROM tablename
    

    This creates a table in the database. Then, use SELECT * FROM INFORMATION_SCHEMA WHERE TABLE_NAME = '_tablename'

    Don't forget to undo the modification to the sproc.

提交回复
热议问题