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

Is there any difference between a NULL and a Blank field in MS SQL Expand / Collapse
Author
Message
Posted Tuesday, October 14, 2008 4:20 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:12 AM
Points: 11, Visits: 94
My question is, is there any difference between a NULL and a Blank
field in MS SQL or are they the same?
I have faced some problems while retrieving the records from the database.How to overcome......
Any one help
Thanks
Shameer
Post #585323
Posted Tuesday, October 14, 2008 4:36 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, September 30, 2013 2:09 AM
Points: 3,131, Visits: 1,058
Both are different.Null is value which is unknown.

If you want to extract the null values use is null

If you want to extract blank values use = ' '



Post #585333
Posted Friday, February 25, 2011 3:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 12, 2014 7:54 AM
Points: 3, Visits: 107

insert into employee(emp_no,emp_fname,emp_lname,dept_no) values(29346,null,'james','d2')
10102 ann jones d3
18316 john barrimore d1
25348 matthew smith d3
29346 james james d2
29347 NULL james d2

insert into employee(emp_no,emp_lname,dept_no) values(29346,'james','d2')
10102 ann jones d3
18316 john barrimore d1
25348 matthew smith d3
29346 james james d2
29347 NULL james d2


so no difference both are same
Post #1069487
Posted Friday, February 25, 2011 4:43 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 8:59 AM
Points: 868, Visits: 1,125
rajasekhar.bollareddy (2/25/2011)

so no difference both are same


An empty string an NULL are the same? Nope.

As stated NULL is an unknown value not an empty string (we know it's a string, we know it's empty).

If your having trouble retrieving things from a column that could be either use ISNULL (look in books online). Use with caution as this can be a performance nightmare.

Carlton.
Post #1069509
Posted Friday, February 25, 2011 5:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 12:40 AM
Points: 7,001, Visits: 8,439
If to you NULL = '' then declare you column NOT NULL !! (maybe even add "with default '' )

there are some nice article regarding NULL and its impact for mistakes .... to happen ....

-http://www.sqlservercentral.com/articles/Advanced+Querying/2829/

- http://www.sqlservercentral.com/articles/T-SQL/understandingthedifferencebetweenisnull/871/

- http://www.sqlservercentral.com/articles/ANSI_NULLs/69234/

- http://www.sqlservercentral.com/articles/Advanced+Querying/gotchasqlaggregatefunctionsandnull/1947/

- http://www.sqlservercentral.com/articles/Advanced/2921/


Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1069520
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse