sqlclr

The difference between the connections strings in SQLCLR

荒凉一梦 提交于 2019-12-02 02:38:52
问题 I was reviewing some code that a consultant checked in and notice they were using SQLCLR. I don't have any experience with it so thought I would research what it was about. I noticed that they used Dim cn As New SqlConnection("server=LOCALHOST;integrated security=yes;database=" & sDb) instead of DIM conn As New SqlConnection("context connection=true") I'm wondering what the difference since it's localhost on the first? 回答1: The context connection uses the user's already established connection

Assemblies in SQL Server keep unloading and loading again periodically

女生的网名这么多〃 提交于 2019-12-02 00:16:37
问题 SQL Server keeps loading and unloading my Assemblies, marking them as unsafe. Any ideas why it would do that. I am attaching the log file down below. 回答1: The Assemblies are being unloaded due to the exact reason stated in the log: memory pressure. There is nothing specific you can do to prevent that (i.e. no option to disable this behavior). The most you can do is reduce the chances of it happening by adding more memory and/or reducing the memory consumption of your queries and/or SQLCLR

Assemblies in SQL Server keep unloading and loading again periodically

六月ゝ 毕业季﹏ 提交于 2019-12-01 22:17:45
SQL Server keeps loading and unloading my Assemblies, marking them as unsafe. Any ideas why it would do that. I am attaching the log file down below. Solomon Rutzky The Assemblies are being unloaded due to the exact reason stated in the log: memory pressure. There is nothing specific you can do to prevent that (i.e. no option to disable this behavior). The most you can do is reduce the chances of it happening by adding more memory and/or reducing the memory consumption of your queries and/or SQLCLR objects. The above suggestions are not meaning that there is anything currently inefficient in

SQL Server — Handling null input in CLR User-Defined Function (UDF) with OnNullCall

大城市里の小女人 提交于 2019-12-01 15:27:52
问题 I have a user-defined function in SQL Server (written in .NET) that cleans text. I'm wondering how to handle null input. Here is the function in C#: [Microsoft.SqlServer.Server.SqlFunction] public static SqlChars cleanEstActText(SqlChars input) { SqlChars cascadingSqlChar = removeNBSP(input); cascadingSqlChar = optimizeFontTags(cascadingSqlChar); return cascadingSqlChar; } This is the error in SQL if the function gets any null data: A .NET Framework error occurred during execution of user

SQL CLR awaitable not getting executed

做~自己de王妃 提交于 2019-12-01 13:53:51
It is my understanding that the awaitable completes the remaining part of the executing code when they return back from the wait. I am trying to get this to work in an sql clr, and this is not working as both awaited process and codes beneath it are not getting executed. In debug method, the control just returns after executing the await line. how can i make this work, as the requirement is for clr to be executed without blocking the main thread so that other work can continue well in the db. I really need this to work, and have been on it for 2 days now. NB This works well if method is sync.

WCF Client Inside SQL CLR

三世轮回 提交于 2019-12-01 09:24:03
问题 I know it's not supported, and I know it's not even a terribly good idea. But, I want to have a WCF client inside a SQL Table Valued Function. I've (seemingly) registered the correct assemblies, but when running my client - I get a WCF error: Msg 6522, Level 16, State 1, Line 1 System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.ChannelFactory`1[MyProxy.IMyService], cannot be used for communication because it is in the Faulted state. A test

SQL Server CLR stored procedures in AWS

那年仲夏 提交于 2019-12-01 08:01:43
I have 2 SQL Server CLR stored procedure s and we are moving database server to AWS . I would like to know if those CLR stored procedures will work after move to AWS? Can use SQL Server CLR stored procedures in AWS? do I need to do anything special? or maybe I need to rewrite them to T-SQL? After additional research I found that it is possible to have SQL Server CLR stored procedures in AWS In the David Iffland article How To Use SQL CLR in Amazon AWS RDS there is step by step instruction how to do it. There is an improvement on the new version of AWS DB Parameter Group and it just require

SQL Server — Handling null input in CLR User-Defined Function (UDF) with OnNullCall

故事扮演 提交于 2019-12-01 04:01:18
I have a user-defined function in SQL Server (written in .NET) that cleans text. I'm wondering how to handle null input. Here is the function in C#: [Microsoft.SqlServer.Server.SqlFunction] public static SqlChars cleanEstActText(SqlChars input) { SqlChars cascadingSqlChar = removeNBSP(input); cascadingSqlChar = optimizeFontTags(cascadingSqlChar); return cascadingSqlChar; } This is the error in SQL if the function gets any null data: A .NET Framework error occurred during execution of user-defined routine or aggregate "removeNBSP": System.Data.SqlTypes.SqlNullValueException: Data is Null. This

SqlFunction fails to open context connection despite DataAccessKind.Read present

烂漫一生 提交于 2019-12-01 03:23:14
I've got a SqlServer project with a very simple test for a Table-Valued-Function:- [SqlFunction(TableDefinition = "forename nvarchar(50)", FillRowMethodName = "TestFillRow", DataAccess = DataAccessKind.Read)] public static IEnumerable TestConn(int ID) { using (SqlConnection con = new SqlConnection("context connection=true")) { //con.Open(); yield return "Anthony"; } } public static void TestFillRow(object obj, out string forename) { forename = (string)obj; } Note the Open on the connection is currently commented out. Once deployed I can execute like this in SQL:- SELECT * FROM [dbo].[TestConn]

SQLCLR and DateTime2

喜欢而已 提交于 2019-12-01 02:53:00
问题 Using SQL Server 2008, Visual Studio 2005, .net 2.0 with SP2 (has support for new SQL Server 2008 data types). I'm trying to write an SQLCLR function that takes a DateTime2 as input and returns another DateTime2. e.g. : using System; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; namespace MyCompany.SQLCLR { public class DateTimeHelpCLR { [SqlFunction(DataAccess = DataAccessKind.None)] public static SqlDateTime UTCToLocalDT(SqlDateTime val) { if (val.IsNull) return SqlDateTime