1,020 questions
2
votes
1
answer
478
views
Accessing the triggered / parent table name inside a SQLCLR trigger
I'm creating a relatively simple SQL CLR in C#.
The job of this CLR is to publish events to an Azure Event Grid Topic.
I would like to be able to call this particular CLR from any number of ...
1
vote
2
answers
947
views
How do I prevent my SQL statements from SQL injection when using CLR/C++ with multiple variables?
I am having a major problem where I do not know how to prevent SQL injection when writing SQL statements in CLR/C++
Below is the code
String^ sqlstr = "SELECT * FROM ";
sqlstr += tableName + " WHERE ...
1
vote
1
answer
506
views
How do I map a credential to a SQLCLR assembly in SQL Server?
I have a CLR assembly in SQL Server which I need to inherit a particular account's permissions. The CLR function basically just grabs a webpage and returns it to SQL in this fashion:
[SqlFunction]...
1
vote
1
answer
79
views
SQL Server SQLCLR function receives parameter error after copying from one DB to another
I am trying to copy the send email assembly from one database to another. I clicked on script assembly as create to and created it in the new db.
When I try to send an email with the function in ...
1
vote
1
answer
383
views
Unicode REGEX in Sql Server CLR function
I have a REGEX SQL CLR function:
var rule1 = new Regex("شماره\\s?\\d{1,10}")
Calling it on SQL Server 2016, however, returns this error:
System.ArgumentException: parsing "?????\s?\d{1,10}" - ...
2
votes
1
answer
837
views
TSQL logging inside transaction using CLR stored procedure
I'm trying to write a log into another database inside a transaction so that the log will survive even if the transaction is rolled back. I've read this answer which says:
One possibility is to use ...
1
vote
1
answer
1k
views
SQL Server 2017 CLR Error: Could Not Find type in assembly
I'm creating a CLR stored procedure in SQL Server 2017. I've done this many times in previous versions without any issue; however, we have recently updated to SQL Server 2017.
I'm aware of the ...
0
votes
0
answers
296
views
How do I add a named HTTPClient in SQLCLR via AddHTTPClient?
I'm following the Microsoft guide found here on how to added a named HTTPClient to my SQL Server with SQLCLR. It all seems straight forward once the HTTPClient is added and I've even got the code to ...
0
votes
1
answer
2k
views
How to get output parameter values of a SQLCLR stored procedure?
I created a SQL Server database project (VS2017) and I added a SQLCLR C# stored procedure. It's declared like this:
public static void RequestServiceToEncryptPassword(byte[] param1, out int param2, ...
2
votes
1
answer
79
views
Converting TSQL code to C# data type problem
I was trying to answer this SO question..
Given the following TSQL code
DECLARE @input1 INT = 100000
DECLARE @input2 INT = 40
DECLARE @input3 INT = 106833
DECLARE @X decimal(22,6) = 0
DECLARE @Y ...
2
votes
2
answers
2k
views
CREATE PROCEDURE gets "Msg 6567, Level 16, State 2" for SQLCLR stored procedure
I have an issue getting SQL Server to create the stored procedure for my CLR function.
This is the error I get:
Msg 6567, Level 16, State 2, Procedure PerfInsert, Line 12 [Batch Start Line 0]
...
1
vote
1
answer
93
views
SQLCLR does not appear to start Windows Application
I'm trying to start a Windows program from SQL Server using SQLCLR. The procedure called does not error, but the program does not appear to start.
Any ideas what I might be doing wrong?
Here is my ....
1
vote
1
answer
99
views
Field order on #region IBinarySerialize
I created IBinarySerialize region in order to create my CLR for my user defined aggregate. I am trying to replicate my XIRR function in C# just to learn how to work with CLRs. I put Write and Read ...
0
votes
1
answer
258
views
ToString Conversion Truncating SqlString Value in SQL CLR
I'm using C# to build a SQL Server CLR procedure. In that I'm trying to convert a SqlString parameter to string, but the result is being truncated.
Here's simplified version of the code. The ...
1
vote
2
answers
957
views
My SQL Server 2008 R2 CLR works sometimes, but not others, but why?
I have a CLR DLL (called clr.dll) which we've previously loaded and used. I'm using it to load a large number of XML files (for which we have no XSD so we can't use the fiddly XML processor in SSIS as ...
0
votes
2
answers
611
views
Using a Socket API in SQL CLR
I'm trying to use a third-party API that is a socket based API with SQL CLR and vb.net. I know how to do this with REST APIs, however, I cannot figure out how to get started with a Socket API.
Does ...
0
votes
0
answers
231
views
SQL CLR triggers with Azure Event Hub
Is there any way to implement change data capture on SQL to Azure EventHub without using exe?
The code needs to run in the context of SQL Server only
SQL Server Version : 2014
Tried SQL CLR with Azure ...
4
votes
2
answers
3k
views
Using Entity Framework 6 / EF Core inside SQL CLR
Microsoft Azure Tech support has confirmed that all version of .Net 4.XX including 4.7.2 is supported in SQL Server Managed Instance CLR.
We're transforming some portion of Business layer with 4.7.2 ...
-3
votes
1
answer
104
views
NullReferenceException during compilation of a SQLCLR function
I am running a sql server function below on 5 different databases on sql 2016 instance:
select * FROM fn_myfunction('', 0, 0,'30 Apr 2015','1', 0)
And am getting this error message:
Msg 10313, Level ...
0
votes
2
answers
639
views
Invoke delegate on main thread - No UI
I've been reading all sorts of questions that are similar to what I'm trying to do, but different enough that they do not seem to apply. What I have is a C# project to create a CLR stored procedure. ...
2
votes
1
answer
3k
views
TSQL CREATE ASSEMBLY FROM varbinary breaks the class_name parameter
I have migrated my on-premise SQL Server 2008 R2 databases to Azure SQL Server Managed Instance (SQL Server 2017). One database is an archive (read-only) database, one is the OLTP database, and the ...
2
votes
2
answers
350
views
Make SQL Server CLR aggregate similar to native aggregates
I'm comparing my custom CLR aggregate vs AVG (SQL Server 2017). My queries are:
SELECT groupId, Helpers.CustomCLR(value)
FROM table
group by groupId
SELECT groupId, AVG(value)
FROM table
...
1
vote
1
answer
904
views
How to fix 'Cannot load dynamically generated serialization assembly' error
"Cannot load dynamically generated serialization assembly." error when executing a clr function that calls a web service in SQL server 2008 R2.
I have a database project in Visual Studio 2017 which ...
1
vote
1
answer
198
views
References - Include SQLCLRTYPES as a reference
I'm using SqlClrTypes and everything is ok until I give my app to another PC. It crashes and it only works after i install SqlClrTypes on that PC. Can i somehow include it to my project?
4
votes
3
answers
1k
views
SQL Server CLR Int64 to SQLInt64 Specified cast is not valid
I am trying to write a CLR that allows me to run a WMI Query on a SQL Server.
using System;
using System.Data.Sql;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Data....