I have created nested cursor which basically compares column values of one table To column values of another and returns the closest match.
Contents of Tables are say :
(ColumnName and Values are as below)
Table A
**Names**
MandarinOrange
SweetApple
SourApple
AppleThatTasteslikeGrapes
Table B
**Names**
PlainOrange
SourOrange
Grapple
.
.
.
So the Cursor1 (outer cursor) takes each name from table1 and compares with all the names in Table2 and returns me the closest match.Cursor 2 (inner) is to retrieve the names in table 2
I am looking to see, if there is a way to acheive the same avaoiding using Cursors
(because it is too slow)
Avoid cursors is always a better practice and in your case, I think it’s also achievable. The key to it is the calculation you perform in order to evaluate the comparison result.
One solution is to create a function takes two strings and return a 1/0 value as the comparison result. Then you can call the function as part of the SELECT statement and save the cursor iteration.
Here’s an example for such a function:
I hope this helps.