
October 20th, 2003, 11:50 AM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Splitting out character strings
Help! I am working with an off-the-shelf shopping cart and now have the data in a MS SQL Server. All of our product options are loaded into one column separated with brackets like this: [Gift Wrap: Birthday] [Frame Color: Black] Each string has the option type (ie Frame Color) and then what the customer selected (ie Black). I need to be able to separate out the options for querys etc.
I have tried to use the charindex and substring functions which gets very complicated and I can't seem to find the end bracket:
SELECT OrderID, Substring(Options, charindex('[Gift Wrap:',Options)+11, charindex('][',Options, charindex('[Gift Wrap:',Options)+11)) AS "GiftWrap"
FROM OrderDetails
I was also wondering if I can somehow create new columns that can hold the parsed data.
I sure would appreciate some help.
thanks
Rick
|