How to access dataset in current scope generated by a call to a stored procedure in TSQL?

前端 未结 3 1906
孤街浪徒
孤街浪徒 2021-02-15 17:29

Problem Background

Generating and accessing data of a fixed column layout is easy. You can create local temp tables up-front, and populate them by calling stored proc

3条回答
  •  粉色の甜心
    2021-02-15 18:22

    Create the temp table before the sp_executesql: it will still be in scope for "inner" scopes like the sp_executesql

    Change the SQL to do an INSERT rather than SELECT..INTO...

    Edit:

    Make the table wide enough to cover all options.

    Frankly, SQL is designed to work with fixed table definitions: variable output signatures (tables) leads to the problem you have...

提交回复
热议问题