Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用我的动态查询可执行文件的结果
execute sp_executesql @query; [it has many columns dependable on variables]
我怎样才能将其导出到#temptable?
#temptable
你不能,除非你事先知道列的数量/类型。如果你这样做(例如基于变量),你可以先创建临时表,然后再做
INSERT INTO #TempTable EXECUTE ...
另一种可能性(不推荐)SELECT INTO ##GlobalTempTable..在您的动态 SQL 内部执行,这样表将可以被外部范围访问。
SELECT INTO ##GlobalTempTable..