If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Running a sql to find blanks or empty space in database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-05, 14:28
newtovb newtovb is offline
Registered User
 
Join Date: Dec 2003
Posts: 3
Exclamation Running a sql to find blanks or empty space in database

I am trying to run a sql to find if any of my fields have a empty or blank space.

Is there anyway we can list such rows and count


Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-09-05, 17:58
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Yes, you can do it.

A lot depends on how you define "empty or blank space" and which database engine you are using. Assuming that your database engine does standard SQL compares (right side string promotion), I'd suggest something like:
Code:
SELECT *
   FROM myTable
   WHERE  myColumn IS  NULL OR '' = myColumn OR myColumn = ' '
-PatP
Reply With Quote
  #3 (permalink)  
Old 03-10-05, 00:22
newtovb newtovb is offline
Registered User
 
Join Date: Dec 2003
Posts: 3
Question blanks for numeric fields

In am using sybase and part of unit testing my application,
I need to see how many blank spaces exist in db.

Especially for fields which have been defined as numeric.
Your query is good for fields defined as characters. Many times we come across db where numeric fields have blanks neither 'NULL' or '0'.

Please do let me know if you have any solution for that.
Reply With Quote
  #4 (permalink)  
Old 03-10-05, 00:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
i'm not sure how to tell you this, but "fields which have been defined as numeric" cannot have blanks or spaces in them

unless sybase is really a lot different than i thought it was
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-10-05, 01:03
derrickleggett derrickleggett is offline
Registered User
 
Join Date: Apr 2004
Location: Kansas City, MO
Posts: 734
Wouldn't that make life interesting. Maybe we could also have a stateless value. hmmmm
__________________
MeanOldDBA
derrickleggett@hotmail.com
When life gives you a lemon, fire the DBA.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On