hojohappy
asked on
Help with MS SQL Server Select Command
I need help creating SQL Select command to perform a look up against another table with the ability to transform the values. Not sure if this is even possible with a SQL Server but thought I would give it try anyway. So here is what I need.
I need a SQL Select command to match data from table1 to table2 based on this rule:
- remove spaces from number
- If length of Table1.Number = 14,
search Table2.GTIN Number Column
- ElseIF length is 10,
Search on UPC Column
Table1 (1 column) Table2 ( 2 columns)
-------------------------- --- -------------------------- ---------- ---------- ----
Number UPC Number GTIN Number
000 38000 10061 1 0000000000 00038000100611
38000 00010 3800000010
Expected Results:
COL1
00038000100611
3800000010
I need a SQL Select command to match data from table1 to table2 based on this rule:
- remove spaces from number
- If length of Table1.Number = 14,
search Table2.GTIN Number Column
- ElseIF length is 10,
Search on UPC Column
Table1 (1 column) Table2 ( 2 columns)
--------------------------
Number UPC Number GTIN Number
000 38000 10061 1 0000000000 00038000100611
38000 00010 3800000010
Expected Results:
COL1
00038000100611
3800000010
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.