Accessing TSQL created #temp tables from CLR stored procedure. Is it possible?

让人想犯罪 __ 提交于 2019-12-05 10:01:27

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//

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

We can define two types of temp tables in SQL.

  • local
  • global

About local temp tables:

When table is preceded by single ‘#’ sign, it is defined as local temporary table and its scope is limited to session in which it is created.

And about global temp tables:

In contrast of local temporary tables, global temporary tables are visible across entire instance.

So may you should try using "##" to create a global temp table. (If there is a difference between "connection context" and "session")

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!