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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How do I...

Author  Topic 

etietje
Starting Member

24 Posts

Posted - 2003-01-29 : 15:41:08
take one column that has multiple columns inside that are not delimited and replace the separating spaces with a single comma so I can use it as a CSV?

Here is an example:

Col1
------------------------------------------------------------------
0051916505 032 Amoco T1608 1212 W Tampa Ave
0051916506 032 B Corner Food Mart T1602 118 Clements Bridge Rd
0051916507 032 Texaco Star Mart T1608 594 St Hwy 73

I need to make that into multiple columns somehow. I can easily enough convert from a CSV into a new table, but I'm still at a loss as to how I can get comma's instead of spaces in each row. Thanks in advance for any help.

etietje
Starting Member

24 Posts

Posted - 2003-01-29 : 15:50:18
Nevermind. Thanks anyway. I found a very easy way to do it using Excel :)

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-01-29 : 16:05:17
Well the answer is to use the REPLACE function. Just see the example in BOL if you decide not to use the Excel way that you found.

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-01-29 : 16:17:26
I was going to answer with the REPLACE function as well, but does he want "Texaco Star Mart" to be delimited with commas? I.e., turned into "Texaco, Star, Mart"

That to me made this tricky, if not impossible to do logically. Unless there are at least 2 spaces between fields or something along those lines.

- Jeff
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-01-29 : 17:18:56
This is where regular expressions would come in really handy.

Go to Top of Page
   

- Advertisement -