sqlclr

How do I use Entity Framework in a CLR stored procedure?

落花浮王杯 提交于 2019-12-06 08:38:15
问题 I am looking forward to move all the logic (which is implemented as manipulating Entity Framework 4 objects) to a server side. It looks going to be simple (thanks to the application structure) and beneficial (as all I have is one oldy laptop as a client and one tough server which runs SQL Server 2008, and building a separate service for the logic can just introduce more latency if compared to doing it inside the database). So how do I correctly use Entities Framework inside a CLR stored

why would a SQLCLR proc run slower than the same code client side

人走茶凉 提交于 2019-12-06 07:21:30
I am writing a stored procedure that when completed will be used to scan staging tables for bogus data on a column by column basis. Step one in the exercise was just to scan the table --- which is what the code below does. The issue is that this code runs in 5:45 seconds --- however the same code run as a console app (changing the connectionstring of course) runs in about 44 seconds. using (SqlConnection sqlConnection = new SqlConnection("context connection=true")) { sqlConnection.Open(); string sqlText = string.Format("select * from {0}", source_table.Value); int count = 0; using (SqlCommand

SQL CLR for Event Driven Communication

守給你的承諾、 提交于 2019-12-06 06:25:52
问题 Where I work they are using Long Polling techniques to detect events as they occur in the database. While it works...I think everyone would agree polling the database isn't optimal. I would rather attempt some kind of push-technology or technique. As such, I was thinking about using a table trigger to call a SQL CLR object that either drops the event into a queue or calls a web service. There are plenty of examples on how to do this: Call web service from SQL CLR? How to invoke webservice

SQL Server Regular Expression Workaround in T-SQL?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 05:26:19
问题 I have some SQLCLR code for working with Regular Expresions. But now that it is getting migrated into Azure, which does not allow SQLCLR, that's out. I need to find a way to do regex in pure T-SQL. Master Data Services are not available because the dev edition of MSSQL we have is not R2. All ideas appreciated, thanks. Regular expression match samples that need handling (culled from regexlib and other places over the past few years) email address ^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\

SQLCLR Function and System.Runtime.Serialization In GAC

梦想与她 提交于 2019-12-06 03:20:37
问题 I've built a SQLCLR function in C# that will deserialize JSON and return a table. The problem I have is getting the correct assemblies within SQL Server 2012. In order to utilize Newtonsoft's deserializer I've had to add the following assemblies to SQL Server: System.ServiceModel.Internals.dll SMDiagnostics.dll System.Runtime.Serialization.dll Newtonsoft.Json.dll This has all gone as planned but when I try to run my function I get the following error: System.IO.FileLoadException: Could not

F# with sqlclr in a reasonably safe way and scripted assembly

送分小仙女□ 提交于 2019-12-06 02:32:05
There exist some blog posts about how to use F# with SQLCLR in SQL Server that are helpful: http://richardminerich.com/2015/12/a-safer-way-to-use-f-with-sql-clr/ , http://thelastexpression.blogspot.com/2012/04/f-agents-and-sqlclr.html , https://rojepp.wordpress.com/2011/08/03/f_on_sqlclr/ , Can the F# core libs be SQLCLR-approved? and for the C# approach: http://www.sqlservercentral.com/Authors/Articles/Solomon_Rutzky/294002/ I am wondering/hoping that with the passage of time there is a blog post out there, which I haven't been able to find yet or an answer here, which addresses how to use F#

Can't attach to SQL Server to debug SQLCLR Stored Procedure

烂漫一生 提交于 2019-12-06 02:25:08
I want to debug a SQLCLR stored procedure in SQL Server. I have been trying to debug an SP in VS2015 Community and in the recently installed VS2017 Community editions without success. I am pretty sure that the problem lies in attaching to SQL Server but as I've done everything I can find mentioned online but to no avail. When creating the database project in SQL Server Express LocalDB everything works fine. If I change the connection string to use my Developer Edition SQL Server, I then get an error. I have done the following: I created a new database. I am the only user of the server and it

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

Why won't SQL Server register my assembly as SAFE?

自闭症网瘾萝莉.ら 提交于 2019-12-05 16:17:57
On SQL Server 2008, I'm attempting to register an assembly that seems to only reference the supported libraries . Here is the T-SQL code that I'm using to register the assembly: create assembly MySpatial from 'c:\Spatial.dll' This results in the following error: Msg 6509, Level 16, State 31, Line 1 An error occurred while gathering metadata from assembly 'Spatial' with HRESULT 0x80004005. However, if I add with permission_set=unsafe , then SQL will execute the command successfully. How can I find out why the error occurred, or why my assembly must be registered as unsafe? I ran into the same

Can't add System.IO.Compression to trusted assemblies in SQL Server

♀尐吖头ヾ 提交于 2019-12-05 15:07:00
I am trying to create a SQLCLR stored procedure in NET 4.5 that fiddles with ZIP files. Obviously System.IO.Compression is not on SQL Server's approved list but this is what I get when I try to add it manually via SQL Server Management Studio. The same happens if I try to execute CREATE ASSEMBLY via a query. Any ideas? Why is this a no-no? I have also tried running this command in SSMS: CREATE ASSEMBLY SystemIOCOMPRESSION FROM 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.IO.Compression.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS ... and the result