There are 2 strings. Those strings may have differences. I need to return the different values "Difference" and the "Position" of those values which are different.
How to find diff between two string in SQL
The above post shows something similar, however, my string isn't delimited by anything so I'm having trouble applying that method. Both strings will always be 24 characters long. However, the differences will vary, so I can't just compare position 1 of String1 to position 1 of String2.
Ideally, representing the variance values less anything which is the same would be better considering that each position has a meaning. However, getting me to just show the difference would be super helpful.
This is ugly, but...
Firstly, get yourself a copy of
NGrams8K
. Then you can do something like this:If you're on a more recent, and supported version of SQL Server, this is actually much easier, with only one scan of the values needed: