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
 General SQL Server Forums
 New to SQL Server Programming
 Deleting anonymous customers

Author  Topic 

deanglen
Yak Posting Veteran

65 Posts

Posted - 2013-01-07 : 14:51:31
Hi

We have a SQL table in our CMS called customer.dbo

This table creates a permanant account for those customers who purchase from us but also creates a temporary one when a customer is on the site. We have a monthly maintenance that usually deletes this anon records but it no longer seems to be working.

There are fields that are given a NULL Value that are required when a customer purchases. Is there any SQL script that will delete these anon records from our SQL table (the fields for example are email, FirstName, LastName) so if these records are NULL what SQL script can I run to remove them?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2013-01-07 : 15:09:01
If the req is that all the fields are null

DELETE FROM yourTable
WHERE COALESCE(email, FirstName, LastName) IS NULL
This won't delete records that have an empty string


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -