Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

null value Expand / Collapse
Author
Message
Posted Wednesday, December 12, 2012 2:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 12, 2014 10:48 PM
Points: 3, Visits: 10
is there many type off null value?
i have table that have null value on 1 of my field.
ex:
id | Name | Info
----------------
01 | A | X
02 | B | null
03 | C | Y

when i try to select all data with null value on info, it didnt show any data or no data in the result.
but when i select all data, there is some data with null value.
i have try selecting with null, 'null', and '' but nothing works.
it happen on 1 of my table. with other table i can selecting data with null value without any problem.

thanks.
Post #1395534
Posted Wednesday, December 12, 2012 3:09 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 5,142, Visits: 4,930
SELECT * FROM table WHERE info IS NULL

A NULL value can not be used in an equals operation as SQL doesnt know if NULL is < > or = to the value you want to compare it to, therefore you must treat is with IS NULL to or wrap the null column in ISNULL() which will then provide a value to the NULL column.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395540
Posted Wednesday, December 12, 2012 3:20 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
it seems that you are unaware of NULL keyword , take help from here
http://www.techrepublic.com/blog/datacenter/handling-null-values-in-sql-server-2005/153
PLUS
you query will work like this
select * from  table where info is null


BUT below wont work
select * from  table where info = null



-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1395548
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse