The Code is as follows:
Copy codeThe Code is as follows:
Use tempdb
Go
If (object_id ('fn _ getarray') is not null)
Drop function dbo. fn_getArray
Go
Create function fn_getArray (@ every 1 varchar (8000), @ every 2 varchar (8000 ))
Returns varchar (8000)
As
Begin
Declare @ str varchar (8000)
Set @ str ='
Var a = [''' + replace (@ override 1, ',', ''', ''') + '''];
Var B = [''' + replace (@ override 2, ',', ''', ''') + '''];
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,
*/