Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SQL Update to split 1 column into 2

Guest
Sep 07, 2010 Sep 07, 2010

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.

TOPICS
Database access
791
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2010 Sep 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 07, 2010 Sep 07, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources