Hi,
I have a requirements to find string with a hyphen like -RTR but the codes below there are some string that did not give the result specially the 5th records on my sample data. May i ask your assistance on how to make this using t-sql. thank you in advance.
CASE WHEN sal.NAME like '%-RTR%' THEN LEFT(sal.NAME, charindex('-RTR', sal.NAME))+'RTR' ELSE '' END as SKU
--DDL create table #sample (item nvarchar(50)) insert into #sample(item) values('HOT3053-RTR/2937-RTR Motorola DRDRZRMX Housing Frame') insert into #sample(item) values('HOT3053-RTR Motorola DRDRZRMX Housing Frame') insert into #sample(item) values('DAM1615-RTR LP - LCM Assembly') insert into #sample(item) values('Scraped Plastic kit HOT2937-RTR DROIDRAZOR2 Housing Frame') insert into #sample(item) values('INCREDIBLE00193 HHC1035-RTR') Desired result Item1--------------Item2 -------------------------------------------------------- HOT3053-RTR|Motorola DRDRZRMX Housing Frame DAM1615-RTR|LP - LCM Assembly HHC1035-RTR|INCREDIBLE00193