The intersection of two strings in SQL Server is _mssql

Source: Internet
Author: User
Use an array of JavaScript to compute the code as follows:
Copy Code code as follows:

Use tempdb
Go
if (object_id (' Fn_getarray ') is not null)
Drop function dbo. Fn_getarray
Go
Create function Fn_getarray (@ inStr1 varchar (8000), @ inStr2 varchar (8000))
Returns varchar (8000)
As
Begin
DECLARE @ str varchar (8000)
SET @ str = '
var a = ["] + replace (@ inStr1, ', ', ', ', ', ', ', ', ', ') + '"];
var B = ["] + replace (@ INSTR2, ', ', ', ', ', ', ', ', ') +"];
var c= ""
for (Var i=0;i<a.length;i++)
{
for (Var j=0;j<b.length;j++)
{if (A[i]==b[j]&&c.indexof (A[i]) <0)
C+=a[i]+ ","
}
}
'
DECLARE @ object int
DECLARE @ R varchar (800)
exec sp_oacreate ' Msscriptcontrol.scriptcontrol ', @ object output
EXEC sp_OASetProperty @ object, ' Language ', ' JavaScript '
EXEC sp_OAMethod @ object, ' eval ', @ r out, @ str
return @ R
End
Go
SELECT dbo. Fn_getarray (' abc,dced,f23e,gew432 ', ' 23c,abc,f23e,geafd,ged ')
/* Output
abc,f23e,
*/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.