By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

Find empty fields

code green
Expert 100+
P: 1,726
How can empty fields be detected.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM products WHERE 
  2. description IS EMPTY
The field may be NULL
or just empty and I suppose even space characters.
Aug 18 '09 #1
Share this Question
Share on Google+
5 Replies


Delerna
Expert 100+
P: 1,134
Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM products 
  3. WHERE  description IS null OR rtrim(description)=''
  4.  
Aug 18 '09 #2

code green
Expert 100+
P: 1,726
Thanks Delerna
I figured as much, I do something similar in MySql.
Although I once had a regex that achieved this.

But it may need to be RTRIM(LTRIM(description))=''
Aug 19 '09 #3

ck9663
Expert 2.5K+
P: 2,878
also...

Expand|Select|Wrap|Line Numbers
  1. WHERE isnull(rtrim(ltrim(description)),'') = ''
  2.  
Aug 20 '09 #4

code green
Expert 100+
P: 1,726
Expand|Select|Wrap|Line Numbers
  1. WHERE isnull(rtrim(ltrim(description)),'') = '' 
I like that ck9663, although I can't quite see how it works.
It looks like a COALESCE should be there
Aug 20 '09 #5

code green
Expert 100+
P: 1,726
Got it. isnull() function rather than IS NULL
Aug 20 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.