Questions tagged [sqlclr]

SQLCLR (SQL Common Language Runtime) is technology for hosting of the Microsoft .NET common language runtime engine within SQL Server. The SQLCLR allows managed code to be hosted by, and run in, the Microsoft SQL Server environment.

SQL CLR or SQLCLR (SQL Common Language Runtime) is technology for hosting of the Microsoft .NET common language runtime engine within SQL Server. The SQLCLR allows managed code to be hosted by, and run in, the Microsoft SQL Server environment. This technology, introduced in Microsoft SQL Server 2005, allow users for example to create the following types of managed code objects in SQL Server in .NET languages such as C# or VB.NET.

  • Stored procedures (SPs) which are analogous to procedures or void functions in procedural languages like VB or C,
  • triggers which are stored procedures that fire in response to Data Manipulation Language (DML) or Data Definition Language (DDL) events,
  • User-defined functions (UDFs) which are analogous to functions in procedural languages,
  • User-defined aggregates (UDAs) which allow developers to create custom aggregates that act on sets of data instead of one row at a time,
  • User-defined types (UDTs) that allow users to create simple or complex data types which can be serialized and deserialized within the database.

The SQL CLR relies on the creation, deployment, and registration of .NET assemblies, which are physically stored in managed code dynamic load libraries (DLLs). These assemblies may contain .NET namespaces, classes, functions and properties.

Source: http://en.wikipedia.org/wiki/SQL_CLR

1004 questions
10
votes
2 answers

Call web service from SQL CLR?

I have a SQL Server 2012 stored procedure that returns a table. I have to modify that SP to add an additional value to the returned table. Unfortunately, that added value comes from a call to a web-service. From my research, I gather the main ways…
EoRaptor013
  • 1,735
  • 4
  • 18
  • 31
10
votes
1 answer

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

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…
tbone
  • 5,715
  • 20
  • 87
  • 134
10
votes
2 answers

Pass table as parameter to SQLCLR TV-UDF

We have a third-party DLL that can operate on a DataTable of source information and generate some useful values, and we're trying to hook it up through SQLCLR to be callable as a table-valued UDF in SQL Server 2008. Taking the concept here one step…
Skeolan
  • 4,328
  • 2
  • 19
  • 20
10
votes
4 answers

What are IBinarySerialize Interface methods used for?

When you create a custom aggregate function you need to specified the enumeration format: Format Enumeration is used by SqlUserDefinedTypeAttribute and SqlUserDefinedAggregateAttribute to indicate the serialization format of a user-defined type…
gotqn
  • 42,737
  • 46
  • 157
  • 243
9
votes
2 answers

SQL CLR Debugging getting "Canceled by user"

When I'm trying to debug a SQL CLR via a SQL Test script in VS2010 (with MSSQL 2008) I get "Canceled by user" in the Debug output window as soon the deployment finish (which is successful.) I have been up and down the Internet and tried all found…
Quintium
  • 499
  • 5
  • 22
9
votes
3 answers

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

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…
Chaki_Black
  • 882
  • 3
  • 12
  • 30
9
votes
1 answer

Cannot find the asymmetric key -- because it does not exist or you do not have permission

I am trying to be able to run a .Net dll through SQL using the CLR - I am doing so unsuccessfully. I am following the instructions here So I am doing the following: CREATE ASYMMETRIC KEY AKEY_SqlClr FROM EXECUTABLE FILE =…
naspinski
  • 34,020
  • 36
  • 111
  • 167
9
votes
2 answers

Is it possible to create an asymmetric key for a .NET framework assembly in SQL Server 2014?

I am developping an SQL Server Database Project in Visual Studio which is in fact a User Defined Function. In this project, I included Json.NET as a reference (using NuGet). I managed to publish (and make work) my assembly and the UDF to my SQL…
MaxiWheat
  • 6,133
  • 6
  • 47
  • 76
9
votes
1 answer

Sending HTTP POST request from SQL Server 2012 or SQL CLR C#

Is there a generally accepted standard way for sending HTTP requests from SQL Server 2012? What I am trying to do is to use a remote server to process a search query and then insert the results back into the SQL Server 2012 database. The remote…
dennis
  • 683
  • 2
  • 5
  • 18
9
votes
4 answers

TSQL: Is there a way to limit the rows returned and count the total that would have been returned without the limit (without adding it to every row)?

I'm working to update a stored procedure that current selects up to n rows, if the rows returned = n, does a select count without the limit, and then returns the original select and the total impacted rows. Kinda like: SELECT TOP (@rowsToReturn) …
Lawtonfogle
  • 974
  • 4
  • 17
  • 32
9
votes
2 answers

Enabling CLR Integration on SQL Server 2008-r2

Looking for Enabling CLR Integration I found this document: http://msdn.microsoft.com/en-us/library/ms131048.aspx that said to use the following code for setting to 1 the "crl enabled" variable. sp_configure 'show advanced options',…
GVillani82
  • 17,196
  • 30
  • 105
  • 172
8
votes
1 answer

Sql Server CLR Functions

While writing a CLR function Sql Server can we use namespaces ? namespace SomeName1.SomeName2 { public static class SomeClass { [SqlFunction] public static SqlString SomeMethod(SqlString input) { // .... …
Debjit
  • 410
  • 5
  • 16
8
votes
2 answers

SQL CLR Procedure Default Parameter in VS2008 deployment?

I know that I can define default values for CLR procedures when creating the procedure in the database, like this: CREATE PROCEDURE [dbo].[ShredXml] ( @InputXml [xml], @AttributeElementHandling [tinyint] = 0, @ConversionHandling…
Tao
  • 13,457
  • 7
  • 65
  • 76
8
votes
1 answer

Microsoft.SqlServer.Server namespace

I'm trying to implement a Common Language Runtime (CLR) assembly to use with SQL Server. For creating dll I'm using Visual Studio 2019. I have the following code from an example tutorial: using System; using System.Collections; using…
Bohdan
  • 158
  • 2
  • 10
8
votes
3 answers

Sql Server CLR file system access from UDF

I wrote a simple UDF that should plot a graphic and save it on disk. Actually, I am using an UDF as a proxy between SQL SERVER and R, so UDF only passes the R script to the R engine from SQL SERVER via DCOM. Everything works fine until I try to plot…
Klark
  • 8,162
  • 3
  • 37
  • 61