从 CLR 存储过程访问 TSQL 创建的 #temp 表.是否可以?

编程入门 行业动态 更新时间:2024-10-11 01:12:48
本文介绍了从 CLR 存储过程访问 TSQL 创建的 #temp 表.是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号.. 我有一个 TSQL 存储过程 tsql__sp__A,它可以做两件事: I have a TSQL Stored Procedure tsql__sp__A which does two things:

(a) 创建一个临时表 #tempTable,其中包含来自复杂 SELECT 查询的 SELECT 数据.

(a) Creates a temp table #tempTable that has SELECT data from a complex SELECT query.

(b) 为对行参数进行计算的每一行调用 CLR 托管存储过程 clr__sp__B.

(b) Calls a CLR managed Stored Procedure clr__sp__B for each row that does computation on row parameters.

问题:是否可以使用相同的连接上下文从 CLR 过程 clr__sp__B 访问 #tempTable?(不,我不想在托管过程中移动或创建另一个 #tempTable)

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)

谢谢.

推荐答案

谢谢 Boj.

但是我发现当你使用context connections=true"时它会打开所有的 SET

However I found that when you use with a "context connections=true" it opens up all the SET

阅读博尔文章

//上下文连接允许您在最初调用代码的同一上下文中执行 SQL 语句//

//The context connection lets you execute SQL statements in the same context that your code was invoked in the first place//

using (SqlConnection connection = new SqlConnection("context connection=true"))
{
    connection.Open();
    // access #temp table
}

这篇关于从 CLR 存储过程访问 TSQL 创建的 #temp 表.是否可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 06:01:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405423.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   CLR   temp   TSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!