clrstoredprocedure

Multi-threaded code in CLR Stored Procs?

戏子无情 提交于 2020-01-11 03:47:05
问题 Are multi-threaded CLR stored procs possible? I have a data-intensive task with lots of potential for parallelization. CLR Stored Procs would be great to remove the overhead of moving the data out of process, my I fear that I'd have to give up parallel computing. What are my options? Note: We're on SQL Server 2005 with plans in the < 4 month range to upgrade to SQL Server 2008 回答1: If is data intensive with potential to parallelization, you should process it in set oriented manner and let SQL

TSQL logging inside transaction using CLR stored procedure

巧了我就是萌 提交于 2020-01-06 02:40:06
问题 I'm trying to write a log into another database inside a transaction so that the log will survive even if the transaction is rolled back. I've read this answer which says: One possibility is to use a CLR stored procedure to do the logging. This can open its own connection to the database outside the transaction and enter and commit the log data. So I created CLR stored procedure using this article: [SqlProcedure] public static void Voice(SqlString procedureName, SqlInt32 id) { Connection =

Calling unmanaged C/C++ DLL functions from SQL Server 2008

怎甘沉沦 提交于 2019-12-23 09:59:36
问题 I have a vast library of C/C++ functions, which needs to be called from SQL Server 2008. I have written a C# adapter class which loads these functions from Win32 DLL with DllImport and exposes them to .Net code. This works perfectly fine in most .Net applications. Now, I was trying to use the same technique with SQL Server CLR. I create a set of CLR functions and stored procedures, which call the adapter class. This does not work as an attempts to load unmanaged DLL results in System

SQL CLR Stored Procedure and Web Service

假如想象 提交于 2019-12-22 08:20:18
问题 I am current working on a task in which I am needing to call a method in a web service from a CLR stored procedure. A bit of background: Basically, I have a task that requires ALOT of crunching. If done strictly in SQL, it takes somewhere around 30-45 mins to process. If I pull the same process into code, I can get it complete in seconds due to being able to optimize the processing so much more efficiently. The only problem is that I have to have this process set as an automated task in SQL

System.InvalidOperationException: Cannot perform CAS Asserts in Security Transparent methods

半城伤御伤魂 提交于 2019-12-13 02:35:11
问题 I have a SQL CLR trigger written in C# 4.0 and deployed on SQL Server 2014. Whenever an insertion happens in a table in SQL Server, this CLR trigger's job is to import that row in an Oracle database. So basically I have to import data in Oracle database whenever an insert query is fired on a table in SQL Server 2014. This is my first CLR SQL trigger project and below is what I am doing: [SecurityCritical] [OraclePermission(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true

Retrieve the sqlobject that fired the trigger in clr

泪湿孤枕 提交于 2019-12-12 06:47:44
问题 I have a generic clr trigger which can be attached to different tables on insert, update, delete. e.g. [Microsoft.SqlServer.Server.SqlTrigger(Event = "FOR UPDATE, INSERT, DELETE")] public static void TriggerHandle() { DataTable dataTable = new DataTable("Test"); SqlTriggerContext myContext = SqlContext.TriggerContext; try { using (SqlConnection conn = new SqlConnection(CONNECTION_STRING)) { conn.Open(); SqlCommand sqlComm = new SqlCommand(); sqlComm.Connection = conn; switch (myContext

Calling a WCF Service from SQL CLR Stored Procedure

跟風遠走 提交于 2019-12-10 11:24:16
问题 I have created a SQL CLR Stored Procedure which will call a WCF Service. I have managed to get all the correct DLL's loaded into SQL Server to get this to work however I now have following error message: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/extensions: Could not load file or assembly 'System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its

Moving C# in Process Functions to SQL Server CLR functions

☆樱花仙子☆ 提交于 2019-12-10 10:13:41
问题 What are the limitations, unexpected pitfalls and performance traits of moving from in process C# code to SQL CLR Functions? We currently have several data heavy processes that run very fast using in process C# Asp.net MVC project without using a db at all. Performance is very important. The application uses a static in memory cache and performs complex operations to arrive at a final result. Cache updating is a bit of a pain and we are considering moving some of these processes to SQL Server

Moving C# in Process Functions to SQL Server CLR functions

徘徊边缘 提交于 2019-12-05 22:09:57
What are the limitations, unexpected pitfalls and performance traits of moving from in process C# code to SQL CLR Functions? We currently have several data heavy processes that run very fast using in process C# Asp.net MVC project without using a db at all. Performance is very important. The application uses a static in memory cache and performs complex operations to arrive at a final result. Cache updating is a bit of a pain and we are considering moving some of these processes to SQL Server queries that would just output the final result so that less data caching is needed at the c# app

SQL CLR Stored Procedure and Web Service

荒凉一梦 提交于 2019-12-05 14:37:35
I am current working on a task in which I am needing to call a method in a web service from a CLR stored procedure. A bit of background: Basically, I have a task that requires ALOT of crunching. If done strictly in SQL, it takes somewhere around 30-45 mins to process. If I pull the same process into code, I can get it complete in seconds due to being able to optimize the processing so much more efficiently. The only problem is that I have to have this process set as an automated task in SQL Server. In that vein, I have exposed the process as a web service (I use it for other things as well)