Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 05:46:29
|
hi all, my two queries below are1declare @chr varchar(130)select @chr=@chr+[end] from show select @chr will give null as output2declare @chr varchar(130)set @chr=''select @chr=@chr+[end] from show select @chr will give expected resultwhuy is this so?thanx in advance |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 05:51:37
|
because in first case @chr is not initialised so it will take NULL value. and concatenation with NULL yields NULL |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:01:27
|
ok,thanks visakh.. the wats the difference between NULL AND '' ???? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:07:37
|
NULL means unknown value. its not stored internally as a value. whereas '' means blank value. All operators like >,<,=.. will work with '' but not with NULL under default conditions. The behaviour can however be changed by changing ANSI NULL settings. |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:10:52
|
ok thanx |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:15:32
|
welcome |
|
|
|
|
|