delete empty rows by query?

G

gandalf

DELETE *
from table1
where myfield is null

if you mean an empty string
where myfield=""
 
B

Brendan Reynolds

If you can define 'empty row' in terms that can be translated into SQL, yes.
But what exactly is an 'empty row'? Do all columns contain Null values? Or
do any of the text columns contain empty strings? What about numeric columns
that may have a default value of zero?

In the simplest scenario, where we define an 'empty row' as a row in which
all columns contain Null values, then the SQL is quite simple ...

DELETE * FROM TableName WHERE FirstColumn IS NULL AND SecondColumn IS NULL
etc.

If text columns may contain empty strings then things start to get more
complicated ...

DELETE * FROM TableName WHERE (FirstColumn IS NULL OR FirstColumn = "") AND
(SecondColumn IS NULL OR SecondColumn = "") etc.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Delete empty rows 2
DLookup and Nz 0
Delete empty rows 1
Question on importing from Excel 3
Delete rows in different tables 7
Linked Table Bringing in Blank rows 4
Delete duplicate record 2
delete empty rows 1

Top