I need to make changes to the below to only extract '2002' as the result.
select REPLACE(REPLACE(SUBSTRING('CKnovelty2002_pouch-5AR-OneSize',1,CHARINDEX('-','CKnovelty2002_pouch-5AR-OneSize',1) - 1),'CKnovelty',''),'CKflower','')
At the moment, I am getting '2002_pouch' as the result which is incorrect. The expected output is '2002'.
Can somebody please help in this regard ?