|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:53 AM
Points: 1,176,
Visits: 778
|
|
tks all for the commentary today too!
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 8:52 AM
Points: 2,574,
Visits: 1,532
|
|
| Interesting question. Thanks!
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 10:57 PM
Points: 1,491,
Visits: 3,008
|
|
Hugo Kornelis (11/28/2011)
roger.plowman (11/28/2011) Using single quotes for both strings and dates is a brain-dead design decision--period.Technically, T-SQL is not using single quotes for both strings and dates. It uses single quotes for strings only. There is no way to have date literals in T-SQL; that's why we have to make do with string literals that will be converted (at execution time) to date or datetime values. </pedantic> Single quotes ARE for strings only, true. So the trouble comes from our getting used to implicit conversions and expecting them based on our human experience. As may have been noticed in the past, MS SQL is not human . We either have to remind ourselves to consider datatypes (as so many QODs do), or look for MS to require explicit conversion, either with a CAST/CONVERT or special delimiters as with the suggested pound-sign notation #2011-11-28#. If I'm voting, I say leave it as is and stay alert.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 5:04 PM
Points: 338,
Visits: 188
|
|
Guilty as charged. I fell for this in a production environment. It was a particularly difficult bug to find. I Did not recognize it was doing the implicit conversion as strings.
Cheers, J
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 10:51 AM
Points: 1,219,
Visits: 13,507
|
|
good question!
rfr.ferrari DBA - SQL Server 2008 MCITP | MCTS
remember is live or suffer twice!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, August 21, 2012 1:15 AM
Points: 191,
Visits: 224
|
|
Ouch, you got me, I assumed implicit conversion without thinking it through. Thanks for the question.
/@devandreas
|
|
|
|