Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value of empty string '' in INT column

Status
Not open for further replies.

pwills

Technical User
Sep 14, 2002
54
GB
INVOICE is type INT.
I was alarmed to discover that:

SELECT TICKET_ID FROM TICKET WHERE INVOICE = ''

returns all the rows where INVOICE is 0 and NOT where it is blank.

How ON EARTH do I retrieve all rows with blank INVOICE?

 
SQL does an implied conversion of empty string '' to 0 when comparing to an INT column. An INT column cannot contain an empty string. It can hold an integer value or be NULL. Change your statment to search for NULL values.

SELECT TICKET_ID FROM TICKET WHERE INVOICE IS NULL
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top