Get column names/types returned from a stored procedure

后端 未结 3 945
粉色の甜心
粉色の甜心 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条回答
  •  Happy的楠姐
    2020-12-15 22:33

    I just ran Profiler to see how Visual Studio does this for the strongly typed dataset drag and drop.

    This is the code it sent.

     SET NO_BROWSETABLE ON; 
     SET FMTONLY ON;
    
    exec dbo.aspnet_Roles_GetAllRoles @ApplicationName=NULL
    

    So I presume there might not be any "more official" way of doing it.

    Obviously you would need to bear in mind that a single stored procedure might return multiple result sets or different result sets dependant on the parameters passed.

    For people on 2012+ another approach might be to use sp_describe_first_result_set

提交回复
热议问题