Results 1 to 7 of 7

Thread: Move all addresses over from accounts to contact

  1. #1
    anicolais is offline Senior Member
    Join Date
    Nov 2009
    Posts
    99

    Default Move all addresses over from accounts to contact

    I imported all my accounts expecting that if i imported the account address it would automatically copy to the contact address as well like it does when you manually enter in information. This didn't happen so I am wondering an easy way that I can take all my accounts billing addresses and move them into the contact primary addresses. I have about 4 contacts for every account.

    Sugar 5.5
    Windows Vista
    Thanks!

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Move all addresses over from accounts to contact

    A simple sql update statement would do the trick. The accounts_contacts table links the accounts to contacts. Use that to create your update statement.

  3. #3
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Move all addresses over from accounts to contact

    I'm feeling the Christmas spirit here:

    For MySQL:
    Code:
    update contacts c
    inner join accounts_contacts ac on c.id = ac.contact_id and ac.deleted = 0
    inner join accounts a on ac.account_id = a.id and a.deleted = 0
    set c.primary_address_street = a.billing_address_street
       ,c.primary_address_city = a.billing_address_city
       ,c.primary_address_state = a.billing_address_state
       ,c.primary_address_postalcode = a.billing_address_postalcode
       ,c.primary_address_country = a.billing_address_country
    where c.deleted = 0
    Update as needed.

  4. #4
    anicolais is offline Senior Member
    Join Date
    Nov 2009
    Posts
    99

    Default Re: Move all addresses over from accounts to contact

    hahaha thank you very much!!!!!!!

  5. #5
    anicolais is offline Senior Member
    Join Date
    Nov 2009
    Posts
    99

    Default Re: Move all addresses over from accounts to contact

    I am using SQL Server and I have no idea how to convert that into a SQL Server Query. Do you by chance know what the query would look like????

  6. #6
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Move all addresses over from accounts to contact

    SQL Server version:

    Code:
    update c
    set c.primary_address_street = a.billing_address_street
       ,c.primary_address_city = a.billing_address_city
       ,c.primary_address_state = a.billing_address_state
       ,c.primary_address_postalcode = a.billing_address_postalcode
       ,c.primary_address_country = a.billing_address_country
    from contacts c
    inner join accounts_contacts ac on c.id = ac.contact_id and ac.deleted = 0
    inner join accounts a on ac.account_id = a.id and a.deleted = 0
    where c.deleted = 0

  7. #7
    anicolais is offline Senior Member
    Join Date
    Nov 2009
    Posts
    99

    Default Re: Move all addresses over from accounts to contact

    Thanks really appreciate it!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2009-11-16, 08:17 PM
  2. how to move history of a contact
    By Rajas in forum Developer Help
    Replies: 1
    Last Post: 2009-09-02, 12:52 PM
  3. more than 2 contact addresses
    By Rudi Mentär in forum Developer Help
    Replies: 3
    Last Post: 2009-02-17, 07:11 AM
  4. Replies: 0
    Last Post: 2008-10-01, 04:20 PM
  5. Replies: 1
    Last Post: 2005-12-01, 09:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •