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,
*/