How to select string between 2 specific characters from SQL Server column? I am trying to select data between the two semicolons.
I have a column A with below data:
Gift Cards; MK-GC-001; 65gl082
Dream Bar Ingredients; OP-STK-040; 650lp82
Stove Logo ID; OP-STK-061; 6508po2
Tamper Proof Sticker; OP-STK-094; GL65082
Pick and Package; PP-001; 6508ap2
Desired output
MK-GC-001
OP-STK-040
OP-STK-061
OP-STK-094
PP-001
I have tried the below code, I am unable to extract the desired output from last line
reverse([A]),substring(reverse(substring(reverse([A]),0, charindex(';',reverse([A]), charindex(';',reverse([A])) + 1))),0, charindex(';',reverse([A]))+1)
Output that I get is
MK-GC-001
OP-STK-04
OP-STK-06
OP-STK-09
PP-001; G