SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Is there any difference between a NULL and a Blank field in MS SQL


Is there any difference between a NULL and a Blank field in MS SQL

Author
Message
shameersinbox
shameersinbox
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 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
Chandra Sekhara Vyas Dhara
Chandra Sekhara Vyas Dhara
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4207 Visits: 1149
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 = ' '



rajasekhar.bollareddy
rajasekhar.bollareddy
Grasshopper
Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)

Group: General Forum Members
Points: 24 Visits: 116
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
Carlton Leach
Carlton Leach
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1072 Visits: 1296
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.
ALZDBA
ALZDBA
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12284 Visits: 8926
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


Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere w00t

- 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 :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search