0

I have a SQL CLR stored procedure written in c# (.NET4). Its purpose is to allow a trigger on a table in a SQL Server 2012 database to call a web service which then processes the data in that table.

However, there are several different databases which will all have triggers using this assembly. My web service needs to know which database is triggered the call to it in order to know where to get the data from.

I could simply add a parameter to my stored procedure but I want to keep things simple from the database side. Is there any way, in .NET, to obtain information about the database to which the assembly is attached?

4

1 回答 1

2

啊,找到了一个:

这仍然会打开与数据库的上下文连接,但这是我能看到的唯一方式。

using (SqlConnection conn = new SqlConnection("context connection=true"))
{
    conn.Open();
    string dbName = conn.Database
}

这是来自MSDN 文章。此外,有关Context Connection的 MSDN 文章。

于 2013-06-14T18:01:13.747 回答