sqlclr

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

不想你离开。 提交于 2019-12-10 09:05:42
问题 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

how to deploy the CLR functions in SQL server 2008

隐身守侯 提交于 2019-12-09 16:42:48
问题 I created a SQL Server Project in VS2008 called 'RegularExpression'.In that Project i created a 'Regex.cs' class and i wrote one function regarding Regular Expression. Then i Build the solution. Now My problem is to deploy this solution in SQL server 2008 through scripts.( not just clicking on Deploy in VS2008 ). I succeeded up to deploy the assmebly of that project in SQL 2008 using CREATE ASSEMBLY <AName> FROM '<path of .dll>' but iam not getting that function i wrote in VS2008 in SQL 2008

T-SQL (varchar(max) vs CLR (string, SqlString, SqlChars)?

对着背影说爱祢 提交于 2019-12-09 16:06:22
问题 I have a problem, that I can't solve. I'm using SQL Server 2005, C# CLR for using outer dll. The problem is at length of parameter. I need to use as function parameter type varchar(max) . If at C# code I use string , SqlSring , I can't use T-SQL type varchar(max) , just varchar(4000) of nvarchar(4000) . I need to say, that can be situations, when I need to use more then 4000 symbols, so I need know, what C# type I need to use for varchar(max) . I have read a lot of articles, and several of

Can the F# core libs be SQLCLR-approved?

十年热恋 提交于 2019-12-09 12:36:22
问题 According to this thread, F# Core must be SQLCLR-approved for assemblies to be marked SAFE . Is this planned? Can it even be done? 回答1: I believe it can be done. However, F# core library is the sole property of Microsoft. This means you can't modify its code and recompile it to match and comply with SQLCLR SAFE. I suggest you add suggestion to Microsoft using Microsoft's connect website. Microsoft connect is at: http://connect.microsoft.com (you have to register and have email account on live

Programatically read SQL Server's query plan suggested indexes for a specific execution of SQL?

一笑奈何 提交于 2019-12-09 11:02:56
问题 If I run this command in SSMS: set showplan_xml on GO exec some_procedure 'arg1', 'arg2','arg3' GO set showplan_xml off GO I get XML output of the full call stack involved in the query execution, as well as any suggested indexes etc. How might one read this from C#? (One use case might be to periodically enable this and log these results in a production environment to keep an eye on index suggestions.) 回答1: This is, for the most part, two separate (though related) questions. Is it possible to

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

空扰寡人 提交于 2019-12-09 06:08:28
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) From prints in SQL code I've found that the xml created by XML RAW preserves the non-English

SQLCLR custom aggregate with multiple sql_variant parameters

爷,独闯天下 提交于 2019-12-09 03:46:41
问题 Hy, I have post a question about CLR User-Defined Aggregates few month ago oon this post. This works like a charm. But now I would like to quite the same functions with the two parameters in sql_variant type. Like in my previous post, the two function would be sMax and sMin and will return the first value depending on the second. I found that the sql_variant type is a object type in C#. But I having difficulties to accumulate and compare the object. What is the best option to compare this two

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

前提是你 提交于 2019-12-08 22:11:34
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; I am relatively new to C# in this capacity and was hoping someone could help point me in the right

C# clr udf for Active Directory group membership

≯℡__Kan透↙ 提交于 2019-12-08 18:48:27
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 context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); // find the group in question

SQL Server 2012 make HTTP 'GET' Request from a stored procedure

对着背影说爱祢 提交于 2019-12-08 10:54:22
问题 I was given a web service that returns a JSON object. My task is to make an HTTP 'GET' request to that web service and store the JSON data retrieved to a table every 5 minutes. I am thinking about creating a stored procedure and then a job that would execute the stored procedure every 5 minutes. My question is, can you make an HTTP request from a stored procedure? Is there a better approach to accomplish this goal? 回答1: I ended up using a CLR function (using C#) to pull the JSON Object from