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
66
votes
4 answers

Difference between scalar, table-valued, and aggregate functions in SQL server?

What is the difference between scalar-valued, table-valued, and aggregate functions in SQL server? And does calling them from a query need a different method, or do we call them in the same way?
Ehsan Jeihani
  • 1,238
  • 2
  • 14
  • 23
51
votes
15 answers

SQL Server stops loading assembly

We have developed an assembly for SQL Server 2008 R2. The assembly has been working for a week. The managed stored proc inside the assembly was working fine for the whole week and then it stops working. We have been seeing this problem couple…
Harvey Kwok
  • 11,713
  • 6
  • 37
  • 59
46
votes
2 answers

SQL Server: Could not find type in the assembly

Assume the assembly dll: using Microsoft.SqlServer.Server; using System.Data.SqlClient; using System.Data.SqlTypes; using System; using System.Text; namespace CLRFunctions { public class T { [SqlFunction(DataAccess =…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
44
votes
1 answer

SQL CLR project in vs2012

After installing the release version of VS2012, I am unable to find SQL CLR proect template. How can I go about creating a project of this type. Thanks!
laconicdev
  • 6,360
  • 11
  • 63
  • 89
41
votes
6 answers

SQL Server: How to list all CLR functions/procedures/objects for assembly

Question: In SQL Server 2005, how can I list all SQL CLR-functions/procedures that use assembly xy (e.g. MyFirstUdp) ? For example a function that lists HelloWorld for query parameter MyFirstUdp CREATE PROCEDURE HelloWorld AS EXTERNAL NAME…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
38
votes
7 answers

How to grant the database owner (DBO) the EXTERNAL ACCESS ASSEMBLY permission?

When I try to create assembly in SQL 2008 from .Net assembly (.Net 3.5) I am getting the below error, error says that I have to set either of the below properties as true, how can I do that? The database owner (DBO) has EXTERNAL ACCESS ASSEMBLY…
Dev
  • 960
  • 2
  • 15
  • 35
36
votes
5 answers

FileLoadException / Msg 10314 Error Running CLR Stored Procedure

Receiving the following error when attempting to run a CLR stored proc. Any help is much appreciated. Msg 10314, Level 16, State 11, Line 1 An error occurred in the Microsoft .NET Framework while trying to load assembly id 65752. The server may be…
homeskillet
  • 1,169
  • 1
  • 10
  • 10
36
votes
5 answers

How to PRINT a message from SQL CLR function?

Is there an equivalent of PRINT 'hello world' which can be called from CLR (C#) code? I'm trying to output some debug information in my function. I can't run the VS debugger because this is a remote server. Thanks!
Serguei
  • 2,910
  • 3
  • 24
  • 34
27
votes
4 answers

SQLCLR database name adds _1 every time I make a change to the project

This is a new phenomenon I am seeing, my Database name is: MySQLCLR, there is a script that always give this name in it: :setvar DatabaseName "MySQLCLR" all of a sudden now, everytime I make any change to my sqlclr project code and re-compile, the …
Pacman
  • 2,183
  • 6
  • 39
  • 70
25
votes
2 answers

The dbType NVarChar is invalid for this constructor

[Microsoft.SqlServer.Server.SqlProcedure] public static void MyMethod() { string connectionString = "context connection=true"; using (SqlConnection connection = new SqlConnection(connectionString)) { …
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
24
votes
1 answer

How to disable "clr strict security" in SQL Server

I enabled clr integration (i.e. SQLCLR) by running: EXEC sp_configure 'clr enabled', 1; RECONFIGURE; Now when I try: EXEC sp_configure 'clr strict security', 0; RECONFIGURE; I get an error saying the setting does not exist: Msg 15123, Level…
jakubiszon
  • 3,229
  • 1
  • 27
  • 41
24
votes
6 answers

SQLCLR using the wrong version of the .NET Framework

During a recent restart of our development server the SQL Server started using .NET 4.0 for the SQLCLR. This means that nothing using the CLR in SQL works, or at least that's my understanding by reading these…
Tobias Rundbom
  • 436
  • 1
  • 3
  • 13
23
votes
3 answers

CLR Strict Security on SQL Server 2017

MSDN on this article says: CLR uses Code Access Security (CAS) in the .NET Framework, which is no longer supported as a security boundary. A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call…
Jesús López
  • 8,338
  • 7
  • 40
  • 66
22
votes
5 answers

Failed to CREATE AN ASSEMBLY in SQL

I've already dived into SQL clr programming. Unfortunately my first attempt is troubled. My C# assembly code is just so: enter code here public partial class FirstCLRRoutines { public static int GetCLRFrameworkMajorVersion() { return…
Mesut
  • 1,845
  • 4
  • 24
  • 32
22
votes
7 answers

Extracting a .NET Assembly from SQL Server 2005

I am trying to help a personal friend (who now also is a client) with a SQL CLR related problem. He has a SQL Server with a database that has 3 .NET assemblies embeded in it. He asked me to help him extract the assemblies from within the database…
Leo Bontemps
  • 437
  • 1
  • 4
  • 9
1
2 3
66 67