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
more ▼

asked May 20, 2012 at 07:29 AM in Default

shalabh2108 gravatar image

40 3 3 3

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
The difference is just whether the type can hold a null value. If not specified, NULL is the default.
more ▼

answered May 21, 2012 at 12:32 PM

Kev Riley gravatar image

Kev Riley ♦♦
53.9k 47 49 76

(comments are locked)
10|1200 characters needed characters left

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.
more ▼

answered May 21, 2012 at 01:19 PM

Grant Fritchey gravatar image

Grant Fritchey ♦♦
103k 19 21 74

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: May 20, 2012 at 07:29 AM

Seen: 734 times

Last Updated: May 21, 2012 at 01:19 PM