Skip to main content
Post Reopened by Paul White
added 362 characters in body
Source Link

I want to create a function/tsql to get strings from the 1st table/data and compare and convert to the value of a second table if the strings match what is on table 2.

Business example.
When a cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching it against a master list of company names in another table.

The query logic Im trying to apply here is to match how many similar strings are in table 1 data to master list data in table 2. Then if the process saw that the strings from table 1 has a match or has the highest similar string it will output what data in table 2. This should be also case sensitive and allows int and special character. See example below.

Example:
Table 1 contains ->

A121B312C33,AB12312C,ABCAB-C,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

It is not only capital letters. It should match what is on the 2nd table whether lower case or upper case with special characters or with integer as well.

I want to create a function/tsql to get strings from the 1st table/data and compare and convert to the value of a second table if the strings match what is on table 2.

Business example.
When a cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching it against a master list of company names in another table.

Example:
Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

It is not only capital letters. It should match what is on the 2nd table whether lower case or upper case with special characters or with integer as well.

I want to create a function/tsql to get strings from the 1st table/data and compare and convert to the value of a second table if the strings match what is on table 2.

Business example.
When a cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching it against a master list of company names in another table.

The query logic Im trying to apply here is to match how many similar strings are in table 1 data to master list data in table 2. Then if the process saw that the strings from table 1 has a match or has the highest similar string it will output what data in table 2. This should be also case sensitive and allows int and special character. See example below.

Example:
Table 1 contains ->

A121B312C33,AB12312C,AB-C,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

It is not only capital letters. It should match what is on the 2nd table whether lower case or upper case with special characters or with integer as well.

Post Closed as "Needs details or clarity" by John Eisbrener, Marcello Miorelli, MDCCL, Michael Green, Paul White
comments -> question
Source Link
Michael Green
  • 25.1k
  • 13
  • 53
  • 98

CreateI want to create a function/tsql to get strings from the 1st table/data and compare and convert if fromto the value of a second table if the strings would match whatswhat is on table 2.

Business example. 
When a cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching isit against a master list of company namenames in another table.

Example: 
Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

It is not only capital letters. It should match what is on the 2nd table whether lower case or upper case with special characters or with integer as well.

Create a function/tsql to get strings from the 1st table/data and compare and convert if from the value of second table if the strings would match whats on table 2.

Business example. When cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching is against a master list of company name in another table.

Example: Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

I want to create a function/tsql to get strings from the 1st table/data and compare and convert to the value of a second table if the strings match what is on table 2.

Business example. 
When a cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching it against a master list of company names in another table.

Example: 
Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

It is not only capital letters. It should match what is on the 2nd table whether lower case or upper case with special characters or with integer as well.

added 252 characters in body
Source Link

Create a function/tsql to get strings from the 1st table/data and compare and convert if from the value of second table if the strings would match whats on table 2.

Business example. When cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching is against a master list of company name in another table.

Example: Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

Create a function/tsql to get strings from the 1st table/data and compare and convert if from the value of second table if the strings would match whats on table 2.

Example: Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF

Create a function/tsql to get strings from the 1st table/data and compare and convert if from the value of second table if the strings would match whats on table 2.

Business example. When cashier mistakenly encoded ABC1231 as company name instead of ABC the report will have an issue showing ABC1231 instead of ABC. We need to correct this by matching is against a master list of company name in another table.

Example: Table 1 contains ->

A121B312C33,AB12312C,ABC,ABC223,AsBCD21,D23EF,D2E2F2,DEF

Table 2 contains ->

ABC,DEF

Output should be:

ABC,ABC,ABC,ABC,ABC,DEF,DEF,DEF
Formatting, removing MSSQL duplication text
Source Link
LowlyDBA - John M
  • 11k
  • 11
  • 45
  • 62
Loading
Source Link
Loading