Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is difference between null and empty in sql server ?
Posted

 
Share this answer
 
v2
Comments
Loganathan.M 9-May-13 7:01am    
Thank You
Have a read of this Wiki Null(SQL)[^].

But basically NULL does not hold a value, where '' (with no spaces) is a value.
 
Share this answer
 
Comments
Loganathan.M 9-May-13 7:01am    
Thank You
HI,

It is vary important part of the sql at the time of insertion, Depends on datatype of column.
If you pass the empty value it assign default value of that datatype as datetime column saved by default value -- " 1900-01-01 00:00:00.000 ".
So this is not favorable condition - so using asp.net your can insert DbNull value to database. Then it contain Null value(Not assign yet).

It is all depends on conditions which we required-- null or empty

Thanks
Asp.Net & C# Blog[^]
 
Share this answer
 
Comments
Loganathan.M 9-May-13 7:12am    
Thank you
NULL                          EmptyString
-----------------------------------------------------------
1. No datatype                   could belong to char/varchar,nvarchar,nchar etc ...datatype
2. occupy 1 bit per column       Occupy 0 bytes
   for each row to state 
   it's NULL 

Happy Coding!
:)
 
Share this answer
 
SQL
SELECT Something FROM Data
WHERE Something = NULL 

Always return false with = !!!

SQL
SELECT Something from Data 
WHERE Something IS NULL


the value of NULL isn't equal to NULL:
SQL
SELECT Something FROM Data
WHERE NULL = NULL OR NULL IS NULL

return FALSE!

With String '' you can use =, but better use IS, IS NOT
 
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