Hi..
I'm very confusion in zero and null value in SQL SERVER ? Please explain null and zero value with an example ?
Thanks.....
Null & Zero in SQL Server
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 19, 2011, 7:12 AM EST
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.
AartiRank #2,383 · 594 reputationPosted Dec 20, 2011, 7:39 PM EST
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.
Vineet Kumar SainiRank #257 · 9.8K reputationPosted Dec 21, 2011, 1:32 PM EST