November 28, 2011 at 9:12 am
tks all for the commentary today too! 🙂
November 28, 2011 at 9:25 am
Thanks for the ¿
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
November 28, 2011 at 11:00 am
Interesting question. Thanks!
November 28, 2011 at 11:05 am
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.
November 28, 2011 at 12:24 pm
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
November 29, 2011 at 3:10 am
good question!
November 29, 2011 at 4:44 am
Ouch, you got me, I assumed implicit conversion without thinking it through. Thanks for the question.
/@devandreas
May 30, 2013 at 6:25 am
1+ for me
Neeraj Prasad Sharma
Sql Server Tutorials
Viewing 8 posts - 31 through 37 (of 37 total)
You must be logged in to reply to this topic. Login to reply