Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi.I have a field with these values:72v5468k85/grayfessin.html?type=cf&product_code=BLP3111&refx=g00gxyuyu222hghdy5/green.html15-48v&product_code=BCD1001&internal=0&refx=lkj100kI need to have the BCD1001 & BLP3111.I mean 7 characters after product_code=plz help me its really urgent.thanks in advanced
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2009-03-06 : 17:34:01
assuming your product_code is always 7 characters (as you say it is) - here's one way:
select substring(f, charindex('product_code=', f) + 13, 7)from ( select '72v5468k85/grayfessin.html?type=cf&product_code=BLP3111&refx=g00gx' f union all select 'yuyu222hghdy5/green.html15-48v&product_code=BCD1001&internal=0&refx=lkj100k' ) YourTableOUTPUT:-------BLP3111BCD1001