Skip to Content
author's profile photo Former Member
Former Member

How user defined data type treat the null values

According to the documentation. using sp_addtype, we specifying null type The null type determines how the user-defined datatype treats nulls. You can create a user-defined datatype with a null type of “null”, “NULL”, “nonull”, “NONULL”, “not null”, or “NOT NULL”.

However, It seems NONULL or NOT NULL provided in the type definition will not prevent the type from accepting the null value. Any idea?

My test is like the following. There is no error raised when assign, the new type variable can have NULL value assigned to it.

Thank you very much.

ASE 16

1> sp_addtype nm , "varchar(20)", "NONULL"

2> go Type added.

(return status = 0)

1> declare @ss nm

2> select @ss = null

3> go

(1 row affected)

1> declare @ss nm

2> select @ss = null

3> select isnull(@ss,"NULLVAL")

4> go

(1 row affected)


NULLVAL (1 row affected)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

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