sqlclr

Are CLR stored procedures preferred over TSQL stored procedures in SQL 2005+?

坚强是说给别人听的谎言 提交于 2019-12-03 01:59:51
My current view is no, prefer Transact SQL stored procedures because they are a lighter weight and (possibly) higher performing option, while CLR procedures allow developers to get up to all sorts of mischief. However recently I have needed to debug some very poorly written TSQL stored procs. As usual I found many of the problems due to the original developer developer having no real TSQL experience, they were ASP.NET / C# focused. So, using CLR procedures would firstly provide a much more familiar toolset to this type of developer, and secondly, the debugging and testing facilities are more

SQL CLR project in vs2012

怎甘沉沦 提交于 2019-12-03 00:56:24
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! All of the various database objects are now created inside of SQL Server database projects. They've removed the distinction between database projects (SQL Scripts) and SQL CLR projects. So it's just File -> New -> Project , Installed -> Templates -> SQL Server , SQL Server Database Project . Then, if you go to Add -> New Item , you'll find various categories on the left, including (confusingly) SQL CLR and SQL CLR C# . The first is for

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

岁酱吖の 提交于 2019-12-02 20:07:43
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 MyFirstUdp.[SQL_CLRdll.MySQLclass].HelloWorld GO after I ran CREATE ASSEMBLY MyFirstUdp FROM 'C:\Users\username\Documents\Visual Studio 2005\Projects\SQL_CLRdll\SQL_CLRdll\bin\Debug\SQL_CLRdll.dll I can list all assemblies and all functions/procedures, but I seem to be unable to associate the assembly to the functions/procedures... Check out the sys.assembly

SQLCLR custom aggregate with multiple parameters

穿精又带淫゛_ 提交于 2019-12-02 17:16:27
问题 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 following values in my table, and I need the oldest employee Name for each Type : Type | Name | Age -------------------------------- Manager | emp 1 | 35 Manager | emp 2 | 42 Developer | emp 3 | 36 Developer | emp 4 | 45 Developer | emp 5 | 22 So I would

SQL Server: Could not find type in the assembly

被刻印的时光 ゝ 提交于 2019-12-02 16:12:37
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 = DataAccessKind.Read)] public static String NormalizeString(String s, String normalizationForm) { NormalizationForm form = NormalizationForm.FormC; if (String.Equals(f, "FormD", StringComparison.OrdinalIgnoreCase)) form = NormalizationForm.FormD; return = s.Normalize(form); } } } Note : Target the assembly to .NET 3.5 as SQL Server doesn't support .NET 4.0 Copy the assembly to a

SQLCLR custom aggregate with multiple parameters

十年热恋 提交于 2019-12-02 08:31:16
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 following values in my table, and I need the oldest employee Name for each Type : Type | Name | Age -------------------------------- Manager | emp 1 | 35 Manager | emp 2 | 42 Developer | emp 3 | 36 Developer | emp 4 | 45 Developer | emp 5 | 22 So I would like to write a query like this to get the result by using my assembly: Select Type, dbo

Msg 6522, Level 16 warning during execution of clr stored procedure

吃可爱长大的小学妹 提交于 2019-12-02 07:42:21
问题 I would like to create SQL Server CLR stored procedure for inserting some rows in a table in SQL Server 2012. Here is my c# code: using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Collections.Generic; public partial class StoredProcedures { [Microsoft.SqlServer.Server.SqlProcedure] public static void InsertingRows () { // Put your code here Random rnd = new Random(); List<int> listtelnumber = new List<int>

(Unfixable) Assembly exists on SQL Server 2014 but it claims it doesn't have it

只谈情不闲聊 提交于 2019-12-02 07:21:15
Update: this problem is not fixable: https://connect.microsoft.com/SQLServer/Feedback/Details/809697 I'm attempting to create a SQL CLR assembly with .net 4.5 and it's telling me it's missing system.servicemodel (even though it's in the .net assembly folders): Assembly 'MySQLCLRProject' references assembly 'system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation

SQLCLR custom aggregate with multiple sql_variant parameters

安稳与你 提交于 2019-12-02 04:33:07
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 object without knowing the type? When using SQL_VARIANT / object , you can determine the type by

Msg 6522, Level 16 warning during execution of clr stored procedure

点点圈 提交于 2019-12-02 04:04:26
I would like to create SQL Server CLR stored procedure for inserting some rows in a table in SQL Server 2012. Here is my c# code: using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Collections.Generic; public partial class StoredProcedures { [Microsoft.SqlServer.Server.SqlProcedure] public static void InsertingRows () { // Put your code here Random rnd = new Random(); List<int> listtelnumber = new List<int>(new int[] { 1525407, 5423986, 1245398, 32657891, 123658974, 7896534, 12354698 }); List<string>