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
0
votes
2 answers

CLR SQL Server 2005 procedure to take stored procedure results as a parameter

I have a stored procedure that returns a rowset that I'd like to pass into a CLR stored procedure to do some advanced calculations. How would I set this up? Take the input? Iterate the rowset within the CLR procedure?
Caveatrob
  • 12,667
  • 32
  • 107
  • 187
0
votes
2 answers

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

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…
0
votes
2 answers

writing t-sql version of .net codes by using sqlclr

i have a lot of methods wrote with.net codes (c#) to using with linq queries. but i have problem to translating methods to t-sql. and i want to convert that to t-sql functions and using that with t-sql queries directly. how?
Sadegh
  • 4,181
  • 9
  • 45
  • 78
0
votes
1 answer

.NET SQL Server UDF Windowing

Is it possible to create a C# SQL Server UDF that can perform functions similar to the built-in Windowing functions? For example, I'd like to write a function that will calculate a moving average. The only documentation I'm finding for .NET UDF's,…
Boone
  • 137
  • 3
  • 14
0
votes
1 answer

VS 2010/SQLServer 2005 debugging hangs

When attempt to debug a SQL CLR Function the debugger hangs. Using VS2010 and SQL 2005.
TonyP
  • 5,655
  • 13
  • 60
  • 94
0
votes
1 answer

CLR enabled Code + Subquery returned more than 1 value

Whenever there is a subquery used to retrieve a column and if it returns more than 1 value an error occurs: Subquery returned more than 1 value This has happend with one of our ssis package which was using a stored procedure which threw this…
Radhi
  • 6,289
  • 15
  • 47
  • 68
0
votes
1 answer

Hide timeout errors in httprequest CLR C#

I have code C# (CLR): var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://sitewait10seconds.com/script.php?param=1"); httpWebRequest.Method = "GET"; httpWebRequest.Timeout = 30; var httpResponse =…
symranger
  • 3
  • 2
0
votes
2 answers

Why does CREATE ASSEMBLY fail with the error 'Unable to resolve token'?

I'm working with some SQL 2005 CLR code written in C#. We have recently altered a few of the functions to allow NULL parameters. We did this by changing parameters from 'double' to 'SqlDecimal' types. We successfully tested the changes in…
Elliveny
  • 2,159
  • 1
  • 20
  • 28
0
votes
1 answer

SQL Server 2008: Exception when excecuting CLR function which tries to access database through a connection

I want to use CLR table-valued function in SQL Server 2008, which accesses a database from inside itself. I've got a permission exception. I am trying to execute function as the same user as under which it was created. So cause of the problem is not…
Timofey
  • 2,478
  • 3
  • 37
  • 53
0
votes
1 answer

SQL CLR how to access username, hostname, and app_name running in safe mode

I have a trigger written in sql clr (sql 2005, .net 3.5) and I need to get at username, hostname and app_name. In TSQL I would simply use select suser_name() select host_name() select APP_NAME() In my .Net code I…
Gratzy
  • 9,164
  • 4
  • 30
  • 45
0
votes
1 answer

SQL CLR created in C# cannot access local cert store

I cannot create SQL CLR to do a decrypt function and encrypt function from cert store with getting the resultant string from a cert. 'System.Security.SecurityException: Request for the permission of type…
djangojazz
  • 14,131
  • 10
  • 56
  • 94
0
votes
2 answers

Stored procedure output to view

I have software which can read only from tables or views. I need to provide this software some data from clr method (for example data from web services). This software will read data like that: select * from my_view WHERE somefield =…
VikciaR
  • 3,324
  • 20
  • 32
0
votes
2 answers

SQL Syntax error CREATE PROCEDURE AS EXTERNAL

Question: If I add IF not exists to a create procedure as external name statement, I get a syntax error... why? Both statements work fine if I run them separately... IF NOT EXISTS ( SELECT * FROM sys.objects WHERE object_id =…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
0
votes
1 answer

"Cannot load dynamically generated serialization assembly" error in SQLCLR stored procedure

I get the following error when I attempt to execute a C# CLR stored procedure from SQL Server 2008 R2: Msg 6522, Level 16, State 1, Procedure PrintShippingDocLabelsToPDF, Line 0 A .NET Framework error occurred during execution of user-defined…
som
  • 1
  • 4
0
votes
2 answers

SQLCLR custom aggregate with multiple parameters

I have trouble understanding of how CLR User-Defined Aggregates work. I have to create some custom CLR aggregates with multiple parameters. The point is to get the value of the first parameter depending on the second. For example, I have the…