sqlclr

Proper / title case in t-sql

时光总嘲笑我的痴心妄想 提交于 2019-12-05 11:46:50
I'm using SQL 2012 RC0, and looking for a function that can convert a column that holds first and last names into proper/title case. I've had a look around SO but can't seem to find anything, if there is another post please let me know and I will close this one. The table column I want to convert is filled from a user entered field from a web front-end, so at times is not entered in a format that can be used for the purpose of populating name fields on reports for customers (appreciate validation at the front-end can be made stricter, however this doesn't solve the problem of the customers

How to have a sql_variant parameter for a SQL CLR stored procedure?

南楼画角 提交于 2019-12-05 11:15:52
How can one add a sql_variant parameter to a SQL CLR stored procedure? Using System.Object does not work, and I don't see any attributes that I can use. [Microsoft.SqlServer.Server.SqlProcedure] public static void ClearOnePartition( SqlString aString , /* I want this to be a sql_variant */ object aVariant ) { //do stuff here } In Mapping CLR Parameter Data from SQL Books Online, Object is listed as the correct type to use to map sql_variant . I created a simple SQL Server project and added the following class to it: public partial class StoredProcedures { [Microsoft.SqlServer.Server

SSRS 2012 Custom Code .NET Framework 4.0 not supported

冷暖自知 提交于 2019-12-05 11:06:10
问题 I was very hopeful that since SQL Server 2012 SQLCLR supports .NET 4.0 that SQL Server Reporting Services (SSRS) 2012 would support .NET 4.0 custom code assemblies. When attempting to upload an rdl (via the Report Manager or via RSBuild) that references .NET 4.0 assemblies, the Reports Manager throws an error stating This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (rsErrorLoadingCodeModule) Is there something I can configure to get SSRS 2012

Accessing TSQL created #temp tables from CLR stored procedure. Is it possible?

让人想犯罪 __ 提交于 2019-12-05 10:01:27
I have a TSQL Stored Procedure tsql__sp__A which does two things: (a) Creates a temp table #tempTable that has SELECT data from a complex SELECT query. (b) Calls a CLR managed Stored Procedure clr__sp__B for each row that does computation on row parameters. Question: Is it possible to access #tempTable from CLR procedure clr__sp__B using the same connection context? (No, I don't want to move or create another #tempTable inside managed procedure) Thanks. Thank you Boj. However I found that when you use with a "context connections=true" it opens up all the SET Read Bol Article //The context

Any Best practice of doing table record insert with SQL CLR store procedure?

喜你入骨 提交于 2019-12-05 07:28:25
问题 Recently we turned a set of complicate C# based scheduling logic into SQL CLR stored procedure (running in SQL Server 2005). We believed that our code is a great SQL CLR candidate because: The logic involves tons of data from sQL Server. The logic is complicate and hard to be done using TSQL There is no threading or sychronization or accessing resources from outside of the sandbox. The result of our sp is pretty good so far. However, since the output of our logic is in form of several tables

Is it safe to change static readonly variables in C# SQLCLR?

风流意气都作罢 提交于 2019-12-05 04:52:51
I wrote some code in C# 6.0 .NET 3.5 CLR assembly with safety level = external_access . Reduced code: public static readonly DataTable warnings_table = init_warnings_table(); public static void set_warning(string msg) { var row = warnings_table.NewRow(); row[1] = DateTime.Now; row[2] = msg; ... warnings_table.Rows.Add(row); } [Microsoft.SqlServer.Server.SqlProcedure] public static SqlInt32 wrapper_func(SqlInt32 param) { return big_func(Param.Value); } int big_func(int param) { SqlBulkCopy bulkcopy; .... set_warning("Message"); .... write_warnings(bulkcopy); warnings_table.Clear(); } What will

TSQL - Executing CLR Permission

孤人 提交于 2019-12-05 01:40:32
问题 I got a sql procedure from a CLR (.net Assembly) that when executed returns an error Msg 6522, Level 16, State 1, Procedure sp_HelloWorld, Line 0 A .NET Framework error occurred during execution of user defined routine or aggregate 'sp_HelloWorld': System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. System.Security.SecurityException: at System

Pass table as parameter to SQLCLR TV-UDF

限于喜欢 提交于 2019-12-05 01:23:03
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 further, I would like to program a CLR Table-Valued Function that operates on a table of source data from the DB. I'm pretty sure I understand what needs to happen on the T-SQL side of things; but, what should the method signature look like in the .NET (C#) code? What would be the parameter datatype for "table data from SQL Server?" e.g. /* Setup */

CLR assembly will not load in 64 bit SQL Server 2005

怎甘沉沦 提交于 2019-12-04 22:36:49
问题 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 [nvarchar](4000) WITH EXECUTE AS CALLER AS EXTERNAL NAME [Ourfunctions].[UserDefinedFunctions].[GLOBAL_FormatString] GO We have never experienced any problems

Deploying SQL CLR Project fails when creating assembly on database

不羁的心 提交于 2019-12-04 19:15:29
I have a folder with 3 dll files in the folder on the server that I'm using to create the assembly. I tried the following code at first and got an error that said it couldn't find the system.data.datasetextensions.dll file on the server and I copied and pasted the dll from my computer to the same folder where my clr project was located and tried running the command again. Create Assembly OoplesCLR from 'c:\ooplesclr\OoplesFinanceCLR.dll' with Permission_set = SAFE GO I'm now getting this error after copying the dll from my computer to the server folder Warning: The Microsoft .NET Framework