sqlclr

How to improve the Replace function in CLR function?

丶灬走出姿态 提交于 2020-03-28 06:15:33
问题 I have a CLR function to replace string values. but it runs a long time. How can I improve this function and make it runs faster? public static SqlString ReplaceValues(String Value) { // Put your code here char[] c = new char[] { '.' }; Value= Value.Trim(); Value = Value.Trim(c); Value = Value.Replace("'", "").Replace(")", " ").Replace("(", " ").Replace("-", " ").Replace("_", " "); Value = Regex.Replace(Value, @"[י", "+[י"); Value = Regex.Replace(Value, @"\s+", " "); return new SqlString

Converting TSQL code to C# data type problem

…衆ロ難τιáo~ 提交于 2020-02-04 03:53:31
问题 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 decimal(22,6) = 0.001 DECLARE @Z decimal(22,6) DECLARE @r decimal(22,6) DECLARE @v decimal(22,6) SET @v = POWER(1/(1+ (@Y/12)), @input2) SET @r = ((@Y/@input2) * @input1) / (1-@v) IF (@r < @input3) SET @Z = @Y + ABS((@X - @Y)/2) ELSE SET @Z = @Y - ABS((@X - @Y) /2) SET @X = @Y SET @Y = @Z WHILE (ABS(

Converting TSQL code to C# data type problem

这一生的挚爱 提交于 2020-02-04 03:53:27
问题 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 decimal(22,6) = 0.001 DECLARE @Z decimal(22,6) DECLARE @r decimal(22,6) DECLARE @v decimal(22,6) SET @v = POWER(1/(1+ (@Y/12)), @input2) SET @r = ((@Y/@input2) * @input1) / (1-@v) IF (@r < @input3) SET @Z = @Y + ABS((@X - @Y)/2) ELSE SET @Z = @Y - ABS((@X - @Y) /2) SET @X = @Y SET @Y = @Z WHILE (ABS(

How do I prevent my SQL statements from SQL injection when using CLR/C++ with multiple variables?

a 夏天 提交于 2020-02-02 13:09:30
问题 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 " + field + " = " + fieldEntity; I need to be able to input correct SQL Injection preventions to this statement. Background code class database { protected: string fieldEntity; string tableName; string field; ... ____ OleDbDataReader^ openData(String^ fieldEntity, String^ field, String^ tableName)

How do I prevent my SQL statements from SQL injection when using CLR/C++ with multiple variables?

断了今生、忘了曾经 提交于 2020-02-02 13:08:53
问题 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 " + field + " = " + fieldEntity; I need to be able to input correct SQL Injection preventions to this statement. Background code class database { protected: string fieldEntity; string tableName; string field; ... ____ OleDbDataReader^ openData(String^ fieldEntity, String^ field, String^ tableName)

How to call C# function in stored procedure

喜你入骨 提交于 2020-01-29 05:12:48
问题 SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that, I have some function in c# which do some complex manipulation with date-time variable now I want to use those functions in SP. First of all IS IT POSSIBLE TO DO THIS. 回答1: Yes, it is possible to use .NET in a SQL Server 2005 database. Be aware that the .NET version supported by SQL Server 2005 is 2.0. Here's a link for an introduction to Making a CLR stored procedure using Visual Studio 回答2: Take a look this

How to call C# function in stored procedure

一曲冷凌霜 提交于 2020-01-29 05:12:25
问题 SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that, I have some function in c# which do some complex manipulation with date-time variable now I want to use those functions in SP. First of all IS IT POSSIBLE TO DO THIS. 回答1: Yes, it is possible to use .NET in a SQL Server 2005 database. Be aware that the .NET version supported by SQL Server 2005 is 2.0. Here's a link for an introduction to Making a CLR stored procedure using Visual Studio 回答2: Take a look this

How do I add c# class library/ class dll in SQL CLR project?

蓝咒 提交于 2020-01-16 01:10:14
问题 How do I add c# class library/ class dll in SQL CLR project ?. I add the class library dll/ class dll but got error in SQL server 2012 during assembly creation Assembly references assembly 'system.runtime.serialization, version=4.0.0.0, culture=neutral, 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 has failed (reason: 2(The system cannot

SQLCLR using the wrong version of the .NET Framework

风格不统一 提交于 2020-01-09 07:13:09
问题 During a recent restart of our development server the SQL Server started using .NET 4.0 for the SQLCLR. This means that nothing using the CLR in SQL works, or at least that's my understanding by reading these sources: http://software.intel.com/en-us/blogs/2009/10/16/sql-server-2008-sqlclr-net-framework-version/ www.sqlskills.com/BLOGS/BOBB/post/On-SQL-Server-and-NET-40.aspx All we get are error messages of this type: Msg 6517, Level 16, State 1, Line 1 Failed to create AppDomain "xxx.dbo[ddl]

Potential performance issues when calling web service from SQL CLR

﹥>﹥吖頭↗ 提交于 2020-01-06 07:29:28
问题 I have a need to call external web service on certain events in my application. I don't want to modify my application and make any dependencies of that external web service. So, I need to think of a way to do this with some sort of external component. One possible approach is that I make database view which will get filled up when some events in my application occurs. Then I will set up trigger on that view which will call CLR function. In that CLR function I will make call to external web