sqlclr

Can SQL CLR triggers do this? Or is there a better way?

走远了吗. 提交于 2019-11-29 10:28:27
I want to write a service (probably in c#) that monitors a database table. When a record is inserted into the table I want the service to grab the newly inserted data, and perform some complex business logic with it (too complex for TSQL). One option is to have the service periodically check the table to see if new records have been inserted. The problem with doing it that way is that I want the service to know about the inserts as soon as they happen, and I don't want to kill the database performance. Doing a little research, it seems like maybe writing a CLR trigger could do the job. I could

CLR Strict Security on SQL Server 2017

混江龙づ霸主 提交于 2019-11-29 06:51:11
问题 MSDN on this article says: CLR uses Code Access Security (CAS) in the .NET Framework, which is no longer supported as a security boundary. A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call unmanaged code, and acquire sysadmin privileges. Beginning with SQL Server 2017, an sp_configure option called clr strict security is introduced to enhance the security of CLR assemblies. clr strict security is enabled by default, and treats SAFE and

Unable to debug .Net Code. Could not attach to process. SQL CLR Remote Debugging

余生颓废 提交于 2019-11-29 05:22:54
I'm trying to debug a CLR based StoredProcedure in Visual Studio 2012 RTM. I have a Sql Database Project. When I try to debug my script file using RightClick -> Execute with debugger it pop ups a warning about harmfulness of attaching a process and when I accept it just say that : Unable to debug .Net Code. Could not attach to SQL Server process on 'Devserver'. I've done many different things : I've added my domain user to sysadmin SQL Server Role. I've run MSVSMON.EXE on the Remote Server and set up it's permissions. I've configured Visual Studio Project's ConnectionString in Properties pane.

Hashing more than 8000 bytes in SQL Server

微笑、不失礼 提交于 2019-11-29 02:18:40
SQL Server's hashing function HASHBYTES has an input limit of 8000 bytes. How do you hash larger strings? You could hash 8k (or 4k or 2k) chunks of the input and then either concatenate those hashes or hash them into a new hash value. This might get difficult though if you have to create a similar algorithm (in an external .NET app for example) to compare hashes created outside of SQL Server. Another option: Lean on SQL Server's CLR integration and perform the hashing in a .NET assembly. You could write a SQL CLR function: [Microsoft.SqlServer.Server.SqlFunction] public static SqlBinary

Advantage of SQL SERVER CLR

前提是你 提交于 2019-11-28 23:37:20
What advantages does SQLServer CLR offer over T-SQL? Is using .NET syntax easier than T-SQL? I see that you can define user types, but I'm not quite clear on why that's better. For example, you could define an email type and it would have a prefix property and a domain property. You could then search on domain or prefix or both. However, I don't see how that's any different from adding a couple of columns one called prefix and one called domain and searching on them individually. Maybe someone has real world reasons why this is better. I'll give one good example: CLR has a built in RegEx

SQL Server stops loading assembly

梦想的初衷 提交于 2019-11-28 17:11:49
We have developed an assembly for SQL Server 2008 R2. The assembly has been working for a week. The managed stored proc inside the assembly was working fine for the whole week and then it stops working. We have been seeing this problem couple times. The way to make it work again is to restart the SQL Server. Msg 10314, Level 16, State 11, Line 4 An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check

How to grant the database owner (DBO) the EXTERNAL ACCESS ASSEMBLY permission?

孤街浪徒 提交于 2019-11-28 16:28:50
问题 When I try to create assembly in SQL 2008 from .Net assembly (.Net 3.5) I am getting the below error, error says that I have to set either of the below properties as true, how can I do that? The database owner (DBO) has EXTERNAL ACCESS ASSEMBLY permission as TRUE The database has the TRUSTWORTHY database property on The assembly is signed with a certificate or an asymmetric key that has a corresponding login with EXTERNAL ACCESS ASSEMBLY permission. The complete error is below, CREATE

SQL Server 2008: How crash-safe is a CLR Stored Procedure that loads unmanaged libraries

懵懂的女人 提交于 2019-11-28 12:38:58
We've got a regular (i.e. not extended) stored procedure in SQL Server 2000 that calls an external exe. That exe, in turn, loads a .dll that came from an SDK and calls some procedures from it (i.e. Init, DoStuff, Shutdown). The only reason we have this external exe thing is because we didn't want to create an extended stored procedure that would call the .dll. We believed that if the dll crashes (an unlikely event but still) then the SQL Server process will crash as well which is not what we wanted. With an external exe, only that exe would crash. Now, we're upgrading to SQL Server 2008 and

How to make this CLR work with 2005?

时光毁灭记忆、已成空白 提交于 2019-11-28 12:01:24
问题 I am trying to make a clr stored procedure for a sql 2005 database that uses .net 3.5 assemblies So first I had to change sql 2005 to recognize system.core as unsafe what I am not too happy about(I rather have had it say SAFE). Now I get this error Msg 6522, Level 16, State 1, Procedure StoredProcedure1, Line 0 A .NET Framework error occurred during execution of user defined routine or aggregate 'StoredProcedure1': System.Security.HostProtectionException: Attempted to perform an operation

SQL Server custom CLR fails with error “Could not load file or assembly or one of its dependencies. The system cannot find the file specified.”

♀尐吖头ヾ 提交于 2019-11-28 11:35:54
问题 I have created a SQL CLR that references the Windows DLL, WindowsBase. For the most part my CLR works just fine but if WindowsBase gets updated in the GAC then I get the error " Assembly in host store has a different signature than assembly in GAC. ". To address this I built my CLR to reference a version of WindowsBase that is not in the GAC. Now when I run my CLR i get the error " Could not load file or assembly 'WindowsBase, Version=4.0.0.0, ...' or one of its dependencies. The system