sqlclr

Performance and usage of CLR functions in SQL

只谈情不闲聊 提交于 2019-12-22 12:54:20
问题 SQL Server allows you to create CLR functions, stored procedures, user types and other objects, for purpose that are really complex to be done inside SQL. But, can someone compare those two things: TSQL Object and CLR Object, in sense of performance, benefits, and so on. What are real situations for usage CLR objects? Is there any best practices proposition for their usage? 回答1: What are real situations for usage CLR objects? SQL Server lacks an aggregate string concatenation function. This

SQL CLR Trigger, How to make an assembly trusted due to transparent code call critical code?

徘徊边缘 提交于 2019-12-22 06:29:00
问题 I have dived into researching the SQL CLR. Unfortunately, my first example has problem with transparent code call to security code . The point is my SQL CLR Trigger is treated as transparent code. And in trigger, I use Quartz to call to Quartz Windows service : var properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "ServerScheduler"; properties["quartz.scheduler.proxy"] = "true"; properties["quartz.scheduler.proxy.address"] = string.Format("tcp://{0}:{1}/{2}

Pass table as parameter to SQLCLR TV-UDF

跟風遠走 提交于 2019-12-22 03:55:50
问题 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

stored procedure in SQL CLR

試著忘記壹切 提交于 2019-12-21 23:22:03
问题 How do you write a stored procedure using C# in SQLCLR? Currently I am using SQL Server Management Studio and I write stored procedures using T-SQL such as create proc sp_item as .... . 回答1: See: Building my first SQL CLR stored procedure CLR Assembly RegEx Functions for SQL Server by Example Choosing between CLR and T-SQL stored procedures: a simple benchmark Basically, there are Visual Studio templates which allow you to get started with SQL CLR projects. Fill in the blanks, write your

newtonsoft.json parser in a C# CLR for SQL Server 2008 R2 - How to deploy?

℡╲_俬逩灬. 提交于 2019-12-21 17:50:50
问题 I have created a CLR which uses the newtonsoft json parser. I need to deploy the CLR . I have created an assembly for the parser dependency: CREATE ASSEMBLY [Newtonsoft.Json] FROM 'C:\share\Release\Newtonsoft.Json.dll' WITH PERMISSION_SET = UNSAFE The above statement throws an error: `Assembly 'Newtonsoft.Json' references assembly 'system.runtime.serialization, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server

TSQL: Is there a way to limit the rows returned and count the total that would have been returned without the limit (without adding it to every row)?

一曲冷凌霜 提交于 2019-12-21 09:07:39
问题 I'm working to update a stored procedure that current selects up to n rows, if the rows returned = n, does a select count without the limit, and then returns the original select and the total impacted rows. Kinda like: SELECT TOP (@rowsToReturn) A.data1, A.data2 FROM mytable A SET @maxRows = @@ROWCOUNT IF @rowsToReturn = @@ROWCOUNT BEGIN SET @maxRows = (SELECT COUNT(1) FROM mytableA) END I'm wanting reduce this to a single select statement. Based on this question, COUNT(*) OVER() allows this,

TSQL: Is there a way to limit the rows returned and count the total that would have been returned without the limit (without adding it to every row)?

ぐ巨炮叔叔 提交于 2019-12-21 09:07:09
问题 I'm working to update a stored procedure that current selects up to n rows, if the rows returned = n, does a select count without the limit, and then returns the original select and the total impacted rows. Kinda like: SELECT TOP (@rowsToReturn) A.data1, A.data2 FROM mytable A SET @maxRows = @@ROWCOUNT IF @rowsToReturn = @@ROWCOUNT BEGIN SET @maxRows = (SELECT COUNT(1) FROM mytableA) END I'm wanting reduce this to a single select statement. Based on this question, COUNT(*) OVER() allows this,

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

坚强是说给别人听的谎言 提交于 2019-12-20 11:55:12
问题 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

CLR UDF returning Varbinary(MAX)

元气小坏坏 提交于 2019-12-20 04:28:08
问题 Is it possible for a SQL CLR User-Defined Function to return the data type varbinary(MAX)? In the documentation it mentions: "The input parameters and the type returned from a scalar-valued function can be any of the scalar data types supported by SQL Server, except rowversion, text, ntext, image, timestamp, table, or cursor." - they don't mention varbinary, but I'm not sure... I have some byte-array data from the .NET side that I need to return to SQL Server from the CLR, and I'm trying to

Security error when calling external web service in visual studio

亡梦爱人 提交于 2019-12-20 04:14:24
问题 I am trying to call an external webservice in visual studio but I am getting the error. System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. System.Security.SecurityException: at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System