sqlclr

how to deploy the CLR functions in SQL server 2008

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 dep...

What are good problems to solve using CLR stored procs?

I have used CLR stores procedures in SQL server for awhile now, but I'm still wondering what the best situations to use them are. MSDN provides some guidelines for use like heavy string manipulation (regex), or replacing T-SQL that declares lots of table variables and cursors. I'm curious to know what problems SO users are solving with...

CLR assembly will not load in 64 bit SQL Server 2005

We use an assembly with some user defined functions in our installation of SQL Server 2005 (32 bit). We deploy this to production with a script like this: CREATE ASSEMBLY [Ourfunctions] AUTHORIZATION [dbo] FROM 0x4D5A9000...000 WITH PERMISSION_SET = SAFE GO CREATE FUNCTION [dbo].[GLOBAL_FormatString](@input [nvarchar](4000)) RETURNS [nv...

Executing a VB.NET DLL From SQL Server

Objective: we want to write a DLL using VB.NET 2008 using .Net 3.5 that performs an HTTP request we then want to call the DLL From SQL Server 2005 (in a trigger) and pass the DLL some variables and get a return value. Where im at in the process. I have created the DLL 'HTTPDLL.dll' Source: Imports System Imports System.Configurati...

Scripting out a loaded SQLCLR Assembly w/o SSMS GUI

How can I script out my loaded SQLCLR assembly without having to go through the GUI? We like to keep the .SQL files in our source control and I would like to be able to regenerate the generated .sql for an assembly after each build/deploy of the assembly to the test database. It would be nice to know how to use relative paths (and/or ...

Memory pressure notification in SQL CLR

My dear friend google is not able to tell me if there is an API available inside the SQL CLR to get memory pressure notification. It is obviously used, since the AppDomain will get unloaded under memory pressure, but the question is if the notification is sent to into the AppDomain prior to the unload, so that I could release some cache...

'The default schema does not exist' on deploy of SQL CLR assembly onto SQL Server 2008

I'm deploying an example SQL CLR stored procedure which has a SQL CLR type as parameter using Visual Studio 2008 and menu Project -> Deploy. public partial class StoredProcedures { [Microsoft.SqlServer.Server.SqlProcedure] public static void TakeTariff(TariffInfo tariffInfo) { } } public class TariffInfo { public SqlDecimal...

How to refactor T-SQL stored procedure encapsulating it's parameters to a class

On my SQL Server 2008 I have a stored procedure with a large number of parameters. The first part of them is used in every call and parameters from the second part are used rarely. And I can't move the logic to two different stored procedures. Is there a way to encapsulate all this parameters to a class or struct and pass it as a store...

How to add Linq support in SQL CLR

Hi, It is my understanding that System.Core.dll and System.Xml.Linq.dll are supported (or will be) in SQL server 2008. I am trying to use Linq to Objects in my SQL 2008 CLR project. How would I go about "adding" / registering those dlls? (I can't add them as references) Thanks in advance, Orry ...

SQL Server 2008 SQLCLR Issue

I have a SQLCLR that was originally running on SQL Server 2005 DB. I have since rebuilt the CLR to run on SQL Server 2008. The CLR requires a reference to WindowsBase.dll. I added WindowsBase.dll as an assembly to the SQL Server 2008 DB. When I try to use the rebuilt CLR I get the message Could not load file or assembly 'WindowsBase...

Is it possible to create a new T-SQL Operator using CLR Code in SQL Server?

I have a very simple CLR Function for doing Regex Matching public static SqlBoolean RegExMatch(SqlString input, SqlString pattern) { if (input.IsNull || pattern.IsNull) return SqlBoolean.False; return Regex.IsMatch(input.Value, pattern.Value, RegexOptions.IgnoreCase); } It allows me to write a SQL Statement Like. SEL...

SQLCLR and DateTime2

Using SQL Server 2008, Visual Studio 2005, .net 2.0 with SP2 (has support for new SQL Server 2008 data types). I'm trying to write an SQLCLR function that takes a DateTime2 as input and returns another DateTime2. e.g. : using System; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; namespace MyCompany.SQLCLR { public ...

Is it possible to determine by way of T-SQL Query whether a sproc is CLR-based or regular T-SQL-based?

Hey all. I'm integrating a CLR/Assembly-based sproc replacement for an existing sproc that lives within our production database, and I want to write an update script that only drops the old T-SQL-based script and doesn't drop the new one if its already there. Is that possible? ...

SQL Server: How to copy a file (pdf, doc, txt...) stored in a varbinary(max) field to a file in a CLR stored procedure?

I ask this question as a followup of this question. A solution that uses bcp and xp_cmdshell, that is not my desired solution, has been posted here. I am new to c# (since I am a Delphi developer) anyway I was able to create a simple CLR stored procedure by following a tutorial. My task is to move a file from the client file system to ...

.NET framework execution aborted while executing CLR stored procedure?

I constructed a stored procedure that does the equivalent of FOR XML AUTO in SQL Server 2008. Now that I'm testing it, it gives me a really unhelpful error message. What does this error mean? Msg 10329, Level 16, State 49, Procedure ForXML, Line 0 .NET Framework execution was aborted. System.Threading.ThreadAbortException: Thread was...

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 sources: http://software.intel.com/en-us/blogs/2009/10/16/sql-server-2008-sqlclr-net-framework-version/ www.sqlskills.com/BLOGS/...

Passing huge amounts of data as an hexadecimal (0x123AB...) parameter of a clr stored procedure in sql server

I post this question has followup of This question, since the thread is not recieving more answers. I'm trying to understand if it is possible to pass as a parameter of a CLR stored procedure a large amount of data as "0x5352532F...". This is to avoid to send the data directly to the CLR stored procedure, instead of sending ti to a tem...

Receiving SQL Server events from a CLR function

I wrote a CLR class with several methods, which are linked as functions in a SQL Server 2005 database. When several of these functions are used in scope of one transaction or connection, I need another one to be automatically executed to clean up some stuff, at the time of transaction or connection close (either time is good for now, lat...

TSD03006: Function: [dbo].[clr_function] has an unresolved reference to Assembly [CLRAssembly.SQL]

I'm using GDR2 (VSTS2008) to deploy a sql clr function to a target db (server: sql server 2008) via Team Build. The error is obvious in that the assembly does not exist on the target server. But, based on the documentation (Deploying CLR ) that there is on this topic, I'm assuming that by simply adding a reference to the assembly in the ...

How to configure outgoing connections from an SQL stored procedure?

I am working on a .NET project which uses Microsoft SQL server. In this project, I need a CLR stored procedure (written in C#) that uses a remote web service. So, when the stored procedure is executed on the SQL server, it makes web service calls and thus sends packets to a remote location. The problem is that when executing the SP I get...