T-SQL Dynamic SQL and Temp Tables

前端 未结 5 1871
梦毁少年i
梦毁少年i 2020-11-28 11:04

It looks like #temptables created using dynamic SQL via the EXECUTE string method have a different scope and can\'t be referenced by \"fixed\" SQLs in the same stored proced

5条回答
  •  猫巷女王i
    2020-11-28 11:42

    I would strongly suggest you have a read through http://www.sommarskog.se/arrays-in-sql-2005.html

    Personally I like the approach of passing a comma delimited text list, then parsing it with text to table function and joining to it. The temp table approach can work if you create it first in the connection. But it feel a bit messier.

提交回复
热议问题