SQL Alphanumeric Pattern Matching - sql

we ran into an issue where we need to test two varchar numeric strings. So if we had one string like '123456' and '123465'. The character could be swapped at any place in the string. I have no clue what to even Google for help with this, but my hope would be to assign a match ranking percentage. Is that even feasible? Any direction would be extremely appreciated.

You might google "Levenshtein distance". Here's a potentially relevant answer:
Levenshtein distance in T-SQL

Related

Query Chinese characters(utf-8) in Google Big Query

I want to query out titles which contains Chinese characters(ex:數學) from my google dataset, and I hava tried many methods as follows.
Google big query only has LENGTH() function,and it doesn't hava DATALENGTH() to compare the difference of length and datasize.
Then, I try to use REGEXP_MATCH() '[\u4e00-\u9fa5]' to match Chinese characters, but it doesn't work, too.
I can't figure out if there are other methods to solve this problem.
Please help, thank you.
BigQuery's LENGTH function currently has a bug which returns the incorrect STRING length for characters that fall out of the ASCII encoding range: https://code.google.com/p/google-bigquery/issues/detail?id=109
Possible workaround: If you just need an accurate LENGTH count, you could use the REGEXP_REPLACE function to convert your characters into a random ASCII character (such as '_'), and count that:
SELECT '數學',
LENGTH(REGEXP_REPLACE('數學', r'.', '_')) as correct,
LENGTH('數學') as incorrect;

find common misspelled searches in SQL Server

IS there a way to find common misspellings in sql server?For example, if I had a legitimate search… like “Forclosure” instead of “Foreclosure”, is there a way to find the connection within a table without doing LIKE or CASE WHEN?
I’m not 100% sure it will work but you can try experimenting with SOUNDEX function and see if it can give you any results.
SOUNDEX converts an alphanumeric string to a four-character code that is based on how the string sounds when spoken.
For example:
SELECT SOUNDEX ('Smith'), SOUNDEX ('Smythe');
Gives same results for both

Store IMEI in SQL Server / Azure

Do you please have any idea which way should I store the IMEI? Should I store it as a bigint? or may be real or float or varchar? IMEI takes 15 characters and normally it is all numbers without any spaces or seperators.
Are you referring to mobile equipment #'s, as described here ? If you're going to search on partial matches of the number, you'll want to store it as some type of character representation. Any type of integer (or bigint) value is going to make things more challenging when it comes to partial-match searching. Also, if you want to verify the check digit, you need to walk through each digit in the IMEI, so again, a character representation is going to work better in this case.

Need examples for Unicode SQL queries

I need few examples for Unicode SQL queries.
Also, i need to understand fully about Unicode. Pls help.
Both parts of your question are way too broad. For the second part see The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
tsql:
insert into Table1(col1) values(N'unicode text ☻');

Copy substring of one column and copy to another

This is a bit above my level. But am trying to learn. I don't want to seem like I'm just trying to get my homework done but would appreciate any help pointers.
I am trying to find a substring (postcode) in an address column and once found, copy to the post code column
I have the following sql which finds columns that match a postcode pattern.
SELECT Address
FROM tb_member
WHERE (Address LIKE '%[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]%')
Next I presume I need to find the substring index...
This is where I start to get a little flummoxed - Am I heading in the right direction?
So you know you want to SUBSTRING a value - look at what the function requires to make it work:
The string value
The starting point of the substring you want to capture
The length of the substring you want
In SQL Server/TSQL, PATINDEX will be better for this situation than CHARINDEX to get that starting point of the substring.
I gather you know how long the substring will always be?
PATINDEX will return the substring index for you.