从 CLR 存储过程访问 TSQL 创建的#temp 表。 是否可以?
- 我有一个 TSQL 存储过程 tsql__sp__A,它执行两件事:
(a) 创建一个临时表 #tempTable,其中包含来自复杂 SELECT 查询的 SELECT 数据。
(b) 为对行参数进行计算的每一行调用 CLR 管理的存储过程 clr__sp__B。
问题:是否可以使用相同的连接上下文从 CLR 过程 clr__sp__B 访问 #tempTable? (不,我不想在托管过程中移动或创建另一个#tempTable)
谢谢。
- I have a TSQL Stored Procedure tsql__sp__A which does two things:
(a) Creates a temp table #tempTable that has SELECT data from a complex SELECT query.
(b) Calls a CLR managed Stored Procedure clr__sp__B for each row that does computation on row parameters.
Question: Is it possible to access #tempTable from CLR procedure clr__sp__B using the same connection context? (No, I don't want to move or create another #tempTable inside managed procedure)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢日本央行。
但是我发现,当您使用“contextconnections=true”时,它会打开所有 SET
阅读 Bol 文章
//上下文连接允许您在与代码最初被调用的上下文相同的上下文中执行 SQL 语句//
Thank you Boj.
However I found that when you use with a "context connections=true" it opens up all the SET
Read Bol Article
//The context connection lets you execute SQL statements in the same context that your code was invoked in the first place//
我们可以在 SQL 中定义两种类型的临时表。
关于本地临时表:
关于全局临时表:
因此,您可能应该尝试使用“##”来创建全局临时表。 (如果“连接上下文”和“会话”之间存在差异)
We can define two types of temp tables in SQL.
About local temp tables:
And about global temp tables:
So may you should try using "##" to create a global temp table. (If there is a difference between "connection context" and "session")