user-defined-functions

SQL Split function that handles string with delimeter appearing between text qualifiers?

爷,独闯天下 提交于 2019-12-20 06:20:52
问题 There are several SQL split functions, from loop driven, to using xml commands, and even using a numbers table. I haven't found one that supports text qualifiers. Using the example string below, I would like to split on ",", but not when it appears between double or single quotes. Example data: jsmith@anywhere.com, "Sally \"Heat\" Jones" <sally@anywhere.com>, "Mark Jones" <mjones@anywhere.com>, "Stone, Ron" <rstone@anywhere.com> Should return a table: jsmith@anywhere.com "Sally \"Heat\" Jones

Returning column names if there is match in the row, looking for multiple matches [duplicate]

混江龙づ霸主 提交于 2019-12-20 06:03:26
问题 This question already has an answer here : Concatenate column headers if value in rows below is non-blank (1 answer) Closed 2 years ago . I have one table with parts as following; --------------- | Part number | --------------- | 123456 | | 16D345 | | 16E099 | | 490586 | | 970884 | --------------- And another one like so; --------------------------------------------------- | Part number | 940822 | 940922 | 170345 | 940222 | --------------------------------------------------- | 123456 | X | |

PHP function for mysqli connection gives error

纵然是瞬间 提交于 2019-12-20 05:01:10
问题 Newer to creating php functions and mysql. I have function to connect to a database db_conect_nm(). This is in file db_fns.php, and contains the user and password to connect to my db. I created this to have a more secure db connection. I had it in a directory outside of public_html, and got error PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'negoti7'@'localhost' (using password: NO) ... Looking for solutions, I saw comments

PHP function for mysqli connection gives error

筅森魡賤 提交于 2019-12-20 05:01:06
问题 Newer to creating php functions and mysql. I have function to connect to a database db_conect_nm(). This is in file db_fns.php, and contains the user and password to connect to my db. I created this to have a more secure db connection. I had it in a directory outside of public_html, and got error PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'negoti7'@'localhost' (using password: NO) ... Looking for solutions, I saw comments

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

Return Seq[Row] from Spark-Scala UDF

蹲街弑〆低调 提交于 2019-12-20 04:20:55
问题 I am using Spark with Scala to do some data processing. I have XML data mapped to dataframe. I am passing a Row as parameter to the UDF and trying to extract two complex types objects as a list. Spark is giving me following error: Exception in thread "main" java.lang.UnsupportedOperationException: Schema for type org.apache.spark.sql.Row is not supported def testUdf = udf((testInput: Row) => { val firstObject = testInput.getAs[Row]("Object1") val secondObject = testInput.getAs[Row]("Object2")

Deterministic scalar function to get week of year for a date

半腔热情 提交于 2019-12-20 02:52:27
问题 Here is a great way of how to get day of week for a date, Deterministic scalar function to get day of week for a date. Now, could anyone help me to create a deterministic scalar function to get week of year for a date please? Thanks. 回答1: This works deterministically, I can use it as a computed column. datediff(week, dateadd(year, datediff(year, 0, @DateValue), 0), @DateValue) + 1 Test code: ; with Dates(DateValue) as ( select cast('2000-01-01' as date) union all select dateadd(day, 1,

Creating a UDF for MySQL in Delphi

我的未来我决定 提交于 2019-12-20 02:11:18
问题 How do I create a UDF for MySQL using Delphi? Does anyone have any code templates? I want the code template to be integrated in Delphi versions(2007 and upper), so I need these templates to be usable with and without Unicode support. 回答1: For starters, Google reveals: documentation a forum thread an example You need to create a DLL with a few exported functions, as documented. 来源: https://stackoverflow.com/questions/5894258/creating-a-udf-for-mysql-in-delphi

String.Join in SQL

故事扮演 提交于 2019-12-19 19:58:13
问题 i want to select from a Table called RMA (simplified): idRMA| RMA_Number ----------------------- 1 RMA0006701 2 RMA0006730 3 RMA0006736 4 RMA0006739 5 RMA0006742 There is a junction table between RMA and tdefSymptomCode called trelRMA_SymptomCode : fiSymptomCode| fiRMA ----------------------- 1 1 1 2 2 2 5 3 7 3 8 3 2 5 3 5 4 5 5 5 for the sake of completeness, this is tdefSymptomCode : idSymptomCode SymptomCodeNumber SymptomCodeName 1 0000 Audio problem 2 0100 SIM problem 3 0200 Appearance

udf vs direct sql performance

拈花ヽ惹草 提交于 2019-12-19 19:49:35
问题 Using MSSQL 2005 I was playing around today with a Scalar UDF in a where statement to see some of the costs associated with making the call and io differences etc. I'm starting with 2 basic tables. Customer which has 1 million rows. and Purchases which has 100,000. Both have an auto identity column as Primary key. No other indexes defined. DBCC FREEPROCCACHE DBCC DROPCLEANBUFFERS SET STATISTICS IO ON SELECT * FROM Customer C INNER JOIN Purchases P on C.[IDENTITY] = P.CustomerID WHERE P.Amount