sqlclr

Types don't match for creating a CLR Stored Procedure

丶灬走出姿态 提交于 2021-02-20 07:02:58
问题 I have a method in an assembly that looks like this: namespace MyNameSpace { public class MyClass { [Microsoft.SqlServer.Server.SqlProcedure] public static void MyMethod(SqlChars myMessage) { // Stuff here } } } I compile that to a dll and load it into my SQL Server like this: drop assembly MyAssembly create assembly MyAssemblyfrom 'C:\Scripts\MyAssembly.dll' That all works fine. But now I try to run this: CREATE PROCEDURE MySproc @message nvarchar(max) AS EXTERNAL NAME MyAssembly.

SQLCLR .NET Error: Object reference not set to an instance of an object

女生的网名这么多〃 提交于 2021-02-10 14:17:28
问题 I am currently receiving an error when trying to execute a simple SELECT statement that references an assembly that contains the C# code for the Jaro-Winkler distance algorithm. This is my first time working with SQLCLRs. I am able to run the code successfully below without the additional OR statement Example: SELECT * FROM USERS WHERE ( DATE_OF_BIRTH IS NOT NULL AND DBO.JAROWINKLER(CONVERT(VARCHAR(6),DATE_OF_BIRTH,12),@DOB) > 0.9 ) OR ( USERID = @USERID ) However when I include the OR

How to recover Service Broker after restoring database?

不羁的心 提交于 2021-01-25 01:47:15
问题 After db restoring on other server the Service Broker is stopped. The restored db has a Trustworthy Off and now I set it to On to run Broker again. I understand that it is bad practice. Especially after reading articles by solomon-rutzky. I have made as Solomon advised for SQLCLR UNSAFE functions without setting database to TRUSTWORTHY ON. It works fine! How to restore Broker working in case TRUSTWORTHY OFF? 回答1: Trustworthy isn't required to run Service Broker. There is, however, an option

How to recover Service Broker after restoring database?

断了今生、忘了曾经 提交于 2021-01-25 01:43:54
问题 After db restoring on other server the Service Broker is stopped. The restored db has a Trustworthy Off and now I set it to On to run Broker again. I understand that it is bad practice. Especially after reading articles by solomon-rutzky. I have made as Solomon advised for SQLCLR UNSAFE functions without setting database to TRUSTWORTHY ON. It works fine! How to restore Broker working in case TRUSTWORTHY OFF? 回答1: Trustworthy isn't required to run Service Broker. There is, however, an option

How to use Json Parser in CLR Procedure?

浪尽此生 提交于 2020-12-29 04:31:26
问题 I am getting CRAZY trying to use a Json Serializer/Deserializer in my Class Library and import my Assembly in SQL Server. I am working with a WebAPI that response Json string , and I want to create CLR Sql Procedure that call that API and use the api result. I tried 2 ways to Deserialize Json string : 1) System.Web.Script.Serialization 2) System.Runtime.Serialization.Json First one get me this error : Assembly 'system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken

How to use Json Parser in CLR Procedure?

不问归期 提交于 2020-12-29 04:29:25
问题 I am getting CRAZY trying to use a Json Serializer/Deserializer in my Class Library and import my Assembly in SQL Server. I am working with a WebAPI that response Json string , and I want to create CLR Sql Procedure that call that API and use the api result. I tried 2 ways to Deserialize Json string : 1) System.Web.Script.Serialization 2) System.Runtime.Serialization.Json First one get me this error : Assembly 'system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken

Unable to create the tSQLtCLR assembly in SQL Server 2017

…衆ロ難τιáo~ 提交于 2020-04-10 07:57:55
问题 I recently installed SQL Server 2017 Express and localdb (general availablity). While attempting to install the tSQLt framework I've discovered a new security feature implemented in SQL Server 2017: the "clr strict security" option. This new security feature seems to prevent the creation of the tSQLtCLR assembly. The SQL error message states: CREATE or ALTER ASSEMBLY for assembly 'tSQLtCLR' with the SAFE or EXTERNAL_ACCESS option failed because the 'clr strict security' option of sp_configure