For et eksempel på data nedenfor
declare @table table (id int identity(1,1), data varchar(1000), descr varchar(1000))
insert into @table values ('Manufacturer Name : Manufacturer 1 Manufacturer Part : asjdfj','First Manufacturer')
insert into @table values ('Manufacturer Name : Manufacturer 2 Manufacturer Part : asjsadfasdfdfj','Second Manufacturer')
insert into @table values ('Manufacturer Name : Manufacturer 3 Manufacturer Part : er6ty','Third Manufacturer')
du kan bruge
select substring(data,
charindex('Manufacturer Name : ', data) + len('Manufacturer Name : '),
charindex('Manufacturer Part : ',data) - len('Manufacturer Part :') - 2) as Manufacturer_Name
, descr
from @table
Hvis du bemærker, at jeg fjerner 2 tegn i slutningen af understrengen for at fjerne 'M' fra Manufacturer Part
og mellemrummet før selve teksten. Du kan bruge RTRIM
men jeg valgte denne måde.