sqlclr

Avoiding TRUSTWORTHY ON and PERMISSION_SET = UNSAFE using System.Net.Http

旧巷老猫 提交于 2020-01-01 18:30:23
问题 Trying to create a stored procedure from a DLL that I built to use with SQL using CLR Integration. I think I need a signed version of System.Net.Http and explain why below. Any advice or tips would be appreciated. The solution works 100% if I use the command ALTER DATABASE test2 SET TRUSTWORTHY ON Then I Create the assembly using the following commands CREATE ASSEMBLY [System.Net.Http] AUTHORIZATION dbo FROM 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0_

CLR Table-valued function with array argument

坚强是说给别人听的谎言 提交于 2019-12-30 06:11:09
问题 I have a SQL CLR function like this one: public partial class UserDefinedFunctions { [Microsoft.SqlServer.Server.SqlFunction(TableDefinition = "number int", FillRowMethodName = "FillRow")] public static IEnumerable MyClrFunction(object obj) { // read obj array input and then var result = new ArrayList(); result.Add((SqlInt32)1); result.Add((SqlInt32)2); result.Add((SqlInt32)3); return result; } public static void FillRow(object obj, out SqlInt32 number) { number = (SqlInt32)obj; } } I would

Failed to CREATE AN ASSEMBLY in SQL

烈酒焚心 提交于 2019-12-30 03:44:05
问题 I've already dived into SQL clr programming. Unfortunately my first attempt is troubled. My C# assembly code is just so: enter code here public partial class FirstCLRRoutines { public static int GetCLRFrameworkMajorVersion() { return System.Environment.Version.Major; } } And SQL code is: USE master GO CREATE ASSEMBLY [Chapter2.FirstCLRRoutine] FROM 'D:\projeler\SQL_CLR\SQL_CLR\bin\Debug\SQL_CLR.dll' But I get this error message from MSSMSE: Msg 6218, Level 16, State 3, Line 1 CREATE ASSEMBLY

WCF net.tcp service and stored assembly in SQL Server

馋奶兔 提交于 2019-12-25 07:46:26
问题 I have a simple client of WCF service which works with net.tcp protocol. This client should be added to database as stored assembly. From service config: <service name="ServiceDocument.DocService" behaviorConfiguration="TCPServiceBehavior"> <endpoint name="DocServiceTCP" address="net.tcp://localhost:5430/DocService" binding="netTcpBinding" bindingConfiguration="netTcpConfig" contract="ServiceDoc.IDocService"/> <endpoint name="DocServiceMex" address="net.tcp://localhost:5431/mexDocService"

What is the best approach to call web service from azure sql?

和自甴很熟 提交于 2019-12-24 18:19:22
问题 What is the best approach to call web service from azure sql(from stored procedure)? I understand that azure sql doesn't support CLR assemblies(SQLCLR). 回答1: No, you cannot access external resources (network, file system, registry, etc) from Azure SQL Database. Neither SQLCLR nor OLE Automation stored procedures (i.e. sp_OA* ) are available on that platform. Even during the year-and-a-half that Azure SQL Database supported SQLCLR (late 2014 through mid-April 2016), it was SAFE Assemblies only

Hashing web user password in ASP.NET vs SQL CLR

岁酱吖の 提交于 2019-12-24 12:27:57
问题 Are there any security concerns in choosing to hash a user password at the application level in ASP.NET vs at the database level in SQL CLR? I'm seen it done both ways. My thinking is that in the application level, the password is only sent once from the browser to the webserver. In a database implementation, the password is sent a second time to the database for hashing. In the latter case, someone running SQL Server Profiler would be able to see the password sent to the procedure or

Can I store information in a Static Variable in a SQL Server CLR Assembly without using UNSAFE?

ぃ、小莉子 提交于 2019-12-24 11:37:35
问题 I have a natural language processing/sentence tagging routine that has been developed as a sqlserver clr assembly written in c#. The routine requires a model file (developed with training data) about 20MB for the computation and I try to load the model file to a static field when the function is called for the first time. However, it seems PERMISSION_SET=EXTERNAL_ACCESS does not allow write to a static field. Of course having an UNSAFE assembly would address the problem but my DBA doesn't

CLR Stored procedure to execute command

六月ゝ 毕业季﹏ 提交于 2019-12-24 09:48:42
问题 I have written a CLR stored procedure to execute command passed to it as parameter. This is code for the CLR stored procedure; I have registered assembly as "unsafe" in SQL Server and created stored procedure from it. [SqlProcedure] public static int ExecuteCommand(string cmd) { int success = 0; try { EventLog.WriteEntry("MyAppName", "Starting execution " + cmd + " Username: " + System.Security.Principal.WindowsIdentity.GetCurrent().Name + " OR " + Environment.UserName, EventLogEntryType

Use Entity Framework in CLR Stored procedure

我与影子孤独终老i 提交于 2019-12-24 09:28:02
问题 I found a post from seven or so years ago that the Entity Framework could not be used in a CLR stored procedure. Has this been rectified in the past seven or so years? Is an update available that will allow the Entity Framework to work in a CLR stored procedure? 回答1: The normal reason you don't do this is that if you did , you would have to install all of .NET Framework assemblies that EF depends on into the database as unsafe assemblies, and you would have to update them every time the .NET

CLR Stored Procedure with C# throwing errors

ε祈祈猫儿з 提交于 2019-12-24 04:13:00
问题 Hi I am working on making a CLR stored procedure using C#, for which I am learning through examples. Below is what I am trying now public static void GetProductsByPrice(int price) { SqlConnection connection = new SqlConnection("context connection=true"); connection.Open(); string commandText = "SELECT * FROM Products WHERE PRICE < " + price.ToString(); SqlCommand command = new SqlCommand(commandText, connection); SqlDataReader reader = command.ExecuteReader(); // Create the record and specify