从 CLR 存储过程访问 TSQL 创建的 #temp 表.是否可以? [英] Accessing TSQL created #temp tables from CLR stored procedure. Is it possible?

查看:32
本文介绍了从 CLR 存储过程访问 TSQL 创建的 #temp 表.是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我有一个 TSQL 存储过程 tsql__sp__A,它可以做两件事:
  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆