Skip to main content
September 7, 2010
Question

SQL Update to split 1 column into 2

  • September 7, 2010
  • 1 reply
  • 828 views

I have a column in a table that holds both a city and a zip ex. Jackson 44319

I am trying to write an sql update query so that the 2 pieces of info would be split and funneled into their own respective column. For example:

Before

column name: address

Jackson 44319

After

column name:city                             column name: zip

Jackson                                           44319

Here is what I have come up with so far, but it does not work correctly.

Update Table
Set city=Parsename(Replace(address ,',','.'),2),
zip=Parsename(Replace(address ,',','.'),1)

this query basically copies all my info from the address table and puts it into the zip table, and the city table remains null. yet, nothing gets split.

This topic has been closed for replies.

1 reply

Inspiring
September 7, 2010

Does your db have a bulk loading utility?  Do you have access to text manipulation tools such as awk?

If so, using them is probably a better idea than using ColdFusion.

September 7, 2010

good idea!. I just imported the data into excel and split the columns there and then just inported it back. Thanks alot!