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.
Author |
Topic |
faijurrahuman
Starting Member
15 Posts |
Posted - 2012-06-28 : 05:49:33
|
HI ;How to split the csv values in rows , this is my sample stringUNIPAR LLC , IAE Power Products , MID-AM Equipment Inc., Diesel Electrical Equipment, Inc. , K & L Electronics Sales & Service, Inc., Logan Corporation , Morton Manufacturing Company , Hilliard Enterprises, Inc.,PowerRail Distribution Inc. , Hatch & Kirk, Inc., Power Drives, Inc. , MAC Products, Inc. , Sterling Rail Inc. , Motive Power Resources, Inc., Saft America, Inc.I want to split the comma separated vales and one condition is some of the companies having example( Hatch & Kirk, Inc. , MID-AM Equipment Inc.) comma values with in the company name or nothing comma. we need to split the valuesexpected output ;1.UNIPAR LLC2. IAE Power Products3. MID-AM Equipment Inc.4. Diesel Electrical Equipment Inc. ,5. K & L Electronics Sales & Service Inc.6. Logan Corporation7. Morton Manufacturing Company8. Hilliard Enterprises Inc.9. PowerRail Distribution Inc.10 .Hatch & Kirk Inc.11. Power Drives Inc.12. MAC Products Inc.13. Sterling Rail Inc.14 . Motive Power Resources Inc.15 . Saft America Inc.any one help to solve the problemThanksFADEShare Knowledge team |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2012-06-28 : 10:10:50
|
search for CSV on this site - there are hundreds of examples of split functions.for your mal-formed csv which contains embedded commas which are not the separator AND is not delimited with quotes, you could try this:select * from someSplitFunction( replace(yourCSVString, ', inc', ' inc'), ',')Be One with the OptimizerTG |
 |
|
|
|
|
|
|