Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

smalldatetime Expand / Collapse
Author
Message
Posted Thursday, December 30, 2010 11:55 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, March 27, 2014 8:50 AM
Points: 2,163, Visits: 2,184
Thanks for the question, and thanks Hugo for your explanation.

This question was really easy, as I knew the errors couldn't happen as they were stated, so there was only one option left.
Post #1041103
Posted Monday, January 03, 2011 10:41 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 4:44 PM
Points: 8,286, Visits: 8,736
Nice question, terrible explanation. SQL doesn't even have a concept of default values for its various datatypes.

Tom
Post #1041948
Posted Tuesday, January 04, 2011 3:15 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 7:26 AM
Points: 1,658, Visits: 6,002
"Whenever we use any data type we should know it's default value"

I disagree (even ignoring the valid but slightly pedantic points about datatypes not having defaults).

We should never rely on default values in this way, it is prone to error, and hard to read the code.

If you want to assign a value to a date variable, then explicitly assign the value you want, don't give it a value of a different datatype and rely on implict conversion
Post #1042261
Posted Tuesday, January 04, 2011 11:21 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, November 10, 2013 9:48 AM
Points: 36, Visits: 74
Thanks for the question.

The default value for the @date1 is NULL.

Please see below proof. If I am commenting the 'set statement, I am getting @date1 as NULL.


declare @date1 smalldatetime

--set @date1 = 0
print Isnull(@date1,getdate())

Thanks.
Reji P R
Hyderabad


Thanks.

Reji PR,
Bangalore

Post #1042601
Posted Tuesday, January 04, 2011 10:00 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, April 10, 2014 3:42 AM
Points: 890, Visits: 1,179
@rejipr1982: Hugo already mentioned this in his response. Still thanks to evaluate the same.

Thanks
Post #1042810
Posted Wednesday, January 05, 2011 7:59 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:55 AM
Points: 1,520, Visits: 3,035
I cannot recall ever using smalldatetime, and now this QOD gives me good reason to avoid it. A max value in year 2079 implies that anyone attempting to save a few bytes per row with this datatype may be leaving a Y2K-like mess for a future programmer or DBA to clean up.
Post #1043454
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse