question

shalabh2108 avatar image
shalabh2108 asked

Null Data Type

Could anyone explain me with suitable example , What is the difference between Null Data Types and Not Null Data Type ? Whenever we create any user defined data type it will ask whether you want to create null or not null data type. So my Concern here what it will create difference in both case. With Regards, Shalabh Saxena
sql-server-2008sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered
The difference is just whether the type can hold a null value. If not specified, NULL is the default.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered
There is no NULL data type. Each of the data types (with a couple of exceptions) can be NULL. You can require a value, which means that you define that column for a given data type within a table as NOT NULL. Or, you can specify that a given column in the table allows NULL values, by setting it's definition using NULL. You just have to remember that NULL is just that, NULL. It doesn't have any meaning. It's not the same as an empty string, or zero, or an empty set, or even unknown. It's simply not there, NULL. Also a NULL value can't be compared to another value, even another NULL value. So you can't use = or any other comparison operator. Instead you have to use commands that take into account NULL logic such as ISNULL, IS NULL, IS NOT NULL.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.