sqlclr

How to create a SQL CLR stored procedure to get data from a web service and insert results into a SQL Server table

我是研究僧i 提交于 2019-12-08 07:52:05
问题 I need to submit some data to a web service from our SQL Server then capture the results into a SQL Server table. Up to this point I have been looking at creating a SQL CLR (C#) stored procedure to accept a/some parameter(s) and then call the web service and capture the results into a SQL Server table; But I am open to any avenues that might work. My questions are these: Am I barking up the right tree so-to-speak, or is there a better way? Assuming a SQL CLR stored procedure is the best way;

How to pass nvarchar (non-English) to CLR (C#) stored procedure?

喜夏-厌秋 提交于 2019-12-08 06:51:42
问题 Working in Visual Studio, I'm trying to pass an entire row to a CLR stored procedure using FOR XML RAW and a parameter of type SqlXml in C# code (with the intent of processing the row using XmlReader). The row contains nvarchar fields. Everything works correctly when the nvarchar fields contain English/numeric/simple punctuation text, but when any of them contain Hebrew or Russian characters, these characters are turned into question marks. (The same for Russian-only text so not an RTL issue)

How to debug a CLR Stored procedure in VS 2013

只愿长相守 提交于 2019-12-08 05:51:05
问题 I have tried different ways to get this done but nothing works. VS seems to ignore all my breakpoints in the .cs files when I run the test script. I have included a breakpoint in the test script as well but still its not debugging. This is the guide from Microsoft https://msdn.microsoft.com/en-us/library/ms165051(v=vs.100).aspx which I tried, but I don't have "a Set as Default Debug Script" option when I right click on my Script file. 回答1: You might need to also: Run Visual Studio as an Admin

C# clr udf for Active Directory group membership

烈酒焚心 提交于 2019-12-08 05:38:04
问题 My problem is as follows: I need a clr udf (in C#) to query with a given ad-usr the ad-group membership using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.DirectoryServices.AccountManagement; public partial class UserDefinedFunctions { [Microsoft.SqlServer.Server.SqlFunction] public static SqlInt32 check_user_is_part_of_ad_grp(SqlString ad_usr, SqlString ad_grp) { bool bMemberOf = false; // set up domain

SQL Server CLR : how to call WCF Service In CLR SQL stored procedure in Visual Studio 2013 database project

只谈情不闲聊 提交于 2019-12-08 03:14:27
I have Visual Studio 2013. I created a database project. I added a CLR stored procedure to that project, and I want to call a WCF service from it. Can anyone help me? I want be able to change service address without changing my assembly, similar to what I can do in web.config with the endpoint section of my WCF client config. I found this after a lot of searching and spend very much time on this in VS 2014 Create Database Project Called "CLR_Test" Create Library For WCF Client "CLR_Service_Client" Add Serivce Refrence of wcf service to "CLR_Test" then add refrence of "CLR_Service_Client" into

Cannot register stdole assembly in SQL Server 2012

可紊 提交于 2019-12-08 01:03:31
问题 I am in the process of migrating a SQL Server 2008 to 2012 and running into challenges in creating some of the necessary assemblies for a CLR routine. The routine takes a dependency on stdole.dll , but I am unable to create this assembly. My code is as follows: ALTER DATABASE main SET TRUSTWORTHY ON; create assembly [stdole] from 'C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll' WITH PERMISSION_SET = unsafe I am receiving the following error: Warning: The Microsoft

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

淺唱寂寞╮ 提交于 2019-12-07 21:42:26
问题 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();

Should I use SqlString or string as parameter type to SQLCLR UDF's

荒凉一梦 提交于 2019-12-07 16:42:45
问题 What is the difference between the Sqlxxx datatypes and their .NET equivalents? For instance, why and when should I use SqlString and not string ? 回答1: Whenever possible, you should use the SqlTypes types for SQLCLR method parameters. There are only 4 SQL Server datatypes that do not have a matching Sql***** type: TIME : use TimeSpan or TimeSpan? DATETIME2 : use DateTime or DateTime? DATETIMEOFFSET : use TimeZoneOffset or TimeZoneOffset? SQL_VARIANT : use object ( NULL comes through as DbNull

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

柔情痞子 提交于 2019-12-07 16:21:22
问题 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

IN SQL Server is CLR Threadsafe

Deadly 提交于 2019-12-07 16:16:55
问题 I have an interface in CLR between SQL Server and the Exchange Web Services to Sync and send emails between applications. In testing this it works(ed) without any problems; we are seeing sporadic issues in the production environment where longer web service task appear to be have overlapped. My question is very simple and I cant decide from reading the CLR details on MSDN - is CLR Thread Safe or not out of the box. If not what is the best way of making calls to CLR that are thread safe is to