How to return only part of a string field in sql query
Posted on 2010-09-10
I want to extract a very small part of a large nvarchar field containing legacy data in order to update a new table.
From the information in this table I wish to get, amongst other fields which are straightforward, a number that is present embedded in text in only some lines, eg:
Field [Legacy_data] contains 'a random amount of text ( 2.3)Kg another random amount of text'
I want to return only the 2.3 from withing the ()Kg and ONLY from those lines that contain '%)Kg%'. Can this be done easily?