| Author |
Topic |
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:06:22
|
| hi all,declare @datcol datetimeset @datcol='01/01/1900' will @datecol will be treated as '' in its following use..Wats the secret behind tatok thanx in advance |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:10:13
|
| nope. it wont be. As it has an already assigned value. |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:12:27
|
| ok then is there any importance for '01/01/1900' in sqlserver ? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:12:37
|
see the differencedeclare @datcol datetime,@datcol1 datetimeset @datcol='01/01/1900' select @datcol,@datcol1output-------------------------datcol datcol11900-01-01 00:00:00.000 NULL |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:13:56
|
yup. its the starting date in sql server and corresponds to integer 0select CAST (0 AS datetime) |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:20:24
|
| hi visakh, i have a ta ble called errorlist.declare @ddate datetime set @ddate='01/01/1900'select * from ErrorList where @ddate=''this will return all records...why is this so... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:25:57
|
| thats because when it casts '' to datetime it gets 1 Jan 1900 as default date value. see belowselect cast('' as datetime) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:27:47
|
| and this is what books online says which supports this behaviourCharacter data representing only date or only time components will be cast to the datetime data type. The unspecified time component is set to 00:00:00.000, and the unspecified date component is set to 1900-01-01. |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 06:29:34
|
| ok thanx visakh u cleared my doubts... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:30:54
|
Cheers |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-10 : 08:25:26
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/02/empty-string-and-default-values.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|