March 5, 2012 at 6:46 am
rmechaber (3/5/2012)
This was a terribly difficult question: I spent 10 minutes looking for the syntax error, catch, gotcha, trip-up, etc., only to submit the straightforward, correct answer.:-DRich
Same thing here... I looked at it went... "All of them" then went "It's a QOTD, it can't be that straightforward"... spent a while analyzing it... Finally shrugged and went with my initial answer. Yayz
March 5, 2012 at 7:27 am
Great back to basics question. What a way to start my Monday morning, thanks Steve I needed this! :w00t: I use the between keyword quite a bit these day.
March 5, 2012 at 7:54 am
Very good question to test the basics
M&M
March 5, 2012 at 8:01 am
Nice and straight forward. Thanks for the question Steve!
March 5, 2012 at 8:27 am
I was throw off with the drop script at the end. Overanalyzing the question.
March 5, 2012 at 9:01 am
Thanks Steve
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
March 5, 2012 at 10:16 am
March 5, 2012 at 10:20 am
rmechaber (3/5/2012)
This was a terribly difficult question: I spent 10 minutes looking for the syntax error, catch, gotcha, trip-up, etc., only to submit the straightforward, correct answer.:-DRich
I did the same. Getting a little gun shy....
Rob Schripsema
Propack, Inc.
March 5, 2012 at 12:44 pm
Great question!
Thanks Steve
March 5, 2012 at 2:32 pm
I got it right, but i managed myself by a sql-query from a c# code that was using date comparison without casting string-dates to sql-dates and it worked well. I thought it's some trick.
Regards
IM
Igor Micev,My blog: www.igormicev.com
March 5, 2012 at 2:55 pm
Easy question, good for a Monday when starting a new job.
March 5, 2012 at 3:07 pm
That was a nice simple no tricks (and very easy) question. Thanks, Steve.
Tom
March 5, 2012 at 3:08 pm
cengland0 (3/5/2012)
Then, the between was comparing string values. I had to guess that it would automatically convert those to date.
Guess??!! But BETWEEN is an operator requiring 3 arguments of the same type; if the types aren't all the same it tries implicit conversion to the type with highest precedence; date has higher precedence than varchar; so there was no need to guess.
To make things worse, it was using the date in yyyy/mm/dd format (or was it?). All those dates would still be valid in yyyy/dd/mm format too. What date collation was set on the server? Who knows.
Who knows??!! And who cares, as it makes no difference to the answer - whether YMD or YDM those six dates are in ascending order, so they are all "between" the first one and the last one.
Tom
March 5, 2012 at 9:59 pm
I too was looking for the catch for a while and then decided there was none. Nice, basic question. Thanks
March 6, 2012 at 2:26 am
L' Eomot Inversé (3/5/2012)
cengland0 (3/5/2012)
Then, the between was comparing string values. I had to guess that it would automatically convert those to date.Guess??!! But BETWEEN is an operator requiring 3 arguments of the same type; if the types aren't all the same it tries implicit conversion to the type with highest precedence; date has higher precedence than varchar; so there was no need to guess.
Exactly! This was the challenge for me. I didn't know about the implicit conversion to date and I didn't know the precedence of those conversions.
Viewing 15 posts - 16 through 30 (of 49 total)
You must be logged in to reply to this topic. Login to reply