Merge Customer Data via SQL Statement

Apr 09, 2008 4 Replies

Does anyone know the SQL statement needed to merge customers? I'm trying to merge "no-longer-active" customer accounts, under one customer name - "customer". This will help cut down my customer list, while keeping all sales data intact. I've got hundreds of in-active customers that need to be merged under one name, and I'm hoping there's a SQL statement that can do it.



Thanks in advance for your help!


...or, maybe I can delete those out-dated customer accounts without invalidating the item sales data? If I delete a customer, will the item sales data be corrupt, or invalidated?

If deleting the customer accounts won't be an issue, will this SQL statement delete everything associated with the customer?

DELETE FROM Customer WHERE LastVisit < '2006-01-01'

Hi Pooch - remember that you can backup and recreate your database on a separate machine running store operations; there you can do all the testing and playing you want with SQL statements, then once you determine the right way to go, backup your production db and run your statement on your production db.

One of the things you may want to consider is....what are you doing with the customer database you are creating? Are you using addresses for mailers / promos, or email addresses.....? Are you tracking misc info in the custom fields and then reporting against these? If all the answers are "no", it probably makes more sense not to track customers - just make it a store policy that customer should present original receipt for returns/exchanges if you accept these at your store....

If you're not using HQ your delete statement should work okay. It'll delete customer records whose last visit are before that date. You are not affecting transaction info, but by all means certainly create a test db on a separate machine and kick the tires....

H> ...or, maybe I can delete those out-dated customer accounts without

Hey convoluted,

Thanks for the speedy reply. I really only record customer data from internet orders, not store purchases. Recording the customer data works great for loyal repeat customers, but I currently have over 500 customers that haven't reordered since 1/1/2005, and I'd like to remove them from my system. I'd rather not merge them, but rather delete them altogether, but I was just worried that might invalidate the item sales data, or something similar. The only fields I populate for customers is:

First Name Last Name Company City State Zip Telephone Fax Email Shipping Address (if different from Billing) Notes

I don't use any customer data for mailing purposes, so losing that information is no concern for me.

So, you think I'll be ok with deleting the customers altogether? I just don't want to lose sales data associated with my items.

Thanks!!

I ran the SQL script:

DELETE FROM Customer WHERE LastVisit < '2006-01-01'

That was perfect! From what I could see, my sales and item data was left intact. I love to clean the data-house every now and again, and this SQL script did the trick with no ill-effects. Much better than trying to merge the data, which would've be pointless in this case anyway. Thanks for the help!

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required