Hi..
I'm very confusion in zero and null value in SQL SERVER ? Please explain null and zero value with an example ?
Thanks.....
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pravin GhadgePosted Dec 19, 2011, 12:12 PM
Zero is a value which is exist in the database.
Null is a special marker used in Sql to indicate that a data value does not exist in the database
For Eg:
ColumnName Datatype
BirthDate Datetime
BirthDate column can have null value but can't contain zero value.
Vineet Kumar SainiPosted Dec 21, 2011, 6:32 PM
AartiPosted Dec 21, 2011, 12:39 AM
A value of NULL indicates that the value is unknown.
A value of NULL is different from an empty or zero value.
No two null values are equal. Comparisons between two null values, or between a NULL and any other value,
return unknown because the value of each NULL is unknown.
create table test_null
(
tid int identity(1,1),
t_val varchar(20)) ;
go
insert into test_null(t_val) values(default)
go 20
select * from test_null where t_val = null
go
--You will not get any output coz Ansi null is ON
SET ANSI_NULLS Off
select * from test_null
where t_val = null
--Now you'll get all Null Values.