Click here to Skip to main content
15,945,603 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Expert ,


A select statement to test for null or zero on 2 fields in a table and abort the process if they exist

and provide the list of incomplete record.



Table :: Trial

Fields :: idno name advance months
------------------------------------
          001  Pet  400     2
          002  jane         5
          003  hens 300     4
          004  pal  340
          007  sam


request.

1. The list of incomplete records (i.e.) :

idno name advance months
------------------------------------
002  jane         5
004  pal  340
007  sam


2. The process to abort if there is at least one incomple


Thanks
Posted
Updated 24-Sep-14 6:21am
v3
Comments
PhilLenoir 24-Sep-14 12:13pm    
What process? Please remember that we don't see your problem, only what you tell us. Selecting records where field IS NULL is the way to detect null values. If the data is not valid where the fields are null, make the field definitions "not null" and the data can never be created.

SQL
SELECT * FROM Trial WHERE advance IS NULL OR months IS NULL
 
Share this answer
 
Comments
Member 10744248 25-Sep-14 1:08am    
how do you handle when advance is '0' or month '0'
PIEBALDconsult 25-Sep-14 1:09am    
Not in the spec.
Please try the below query.
SQL
SELECT * FROM Trial WHERE ISNULL(advance,'0')<>'0' OR ISNULL(months,'0')<>'0'

Hope it helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900