March 5, 2014 at 8:52 pm
Comments posted to this topic are about the item REPLACE behavior
March 5, 2014 at 9:54 pm
Easy one, thanks.
---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
March 5, 2014 at 11:22 pm
Too easy, no need even to run the code this time π
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
March 5, 2014 at 11:50 pm
nice question .. thanks for sharing
March 6, 2014 at 12:05 am
Interesting caveat, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 6, 2014 at 12:17 am
Nice one thanks.
Hope this helps...
Ford Fairlane
Rock and Roll Detective
March 6, 2014 at 1:00 am
Good question!
In Oracle, the answer is 'ABC'.
Just shows that when you think you know something... sometimes you don't!
March 6, 2014 at 1:32 am
This was removed by the editor as SPAM
March 6, 2014 at 2:04 am
Easy - so why only 68% with correct answers?
March 6, 2014 at 2:18 am
In many programming languages the third argument wouldn't even be evalutated if the second argument didn't appear in the first argument.
All these will just return 'ABC':
SELECT REPLACE('ABC', 'Z', 1)
SELECT REPLACE('ABC', 'Z', CURRENT_TIMESTAMP)
SELECT REPLACE('ABC', 'Z', '#$@%')
This one will return 'ABC' half of the time and NULL the other half.
SELECT REPLACE('ABC', 'Z', CASE WHEN RAND() < 0.5 THEN 'A' END)
I thought of making the problem more complex, but I figured that would result in more people just running the query instead of answering first! π
March 6, 2014 at 2:42 am
paul s-306273 (3/6/2014)
Easy - so why only 68% with correct answers?
Perhaps it wasn't as easy as some of the resident "experts" claim. It's anything but logical behaviour and you can only get the question correct if you know that caveat on the REPLACE function (or if you just run the code).
March 6, 2014 at 3:01 am
Thanks, easy one, it's even documented in BOL. π
/HΓ₯kan Winther
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
March 6, 2014 at 6:56 am
A simple one and we're at 65% correct.
March 6, 2014 at 7:08 am
Koen Verbeeck (3/6/2014)
Interesting caveat, thanks.
+1
March 6, 2014 at 7:16 am
Richard Warr (3/6/2014)
It's anything but logical behaviour and you can only get the question correct if you know that caveat on the REPLACE function (or if you just run the code).
Developer A: "We have a bug in this function. Want me to fix it?"
Developer B: "Nah, just document it as normal behavior."
Developer A: "Done."
-----
a haiku...
NULL is not zero
NULL is not an empty string
NULL is the unknown
Viewing 15 posts - 1 through 15 (of 25 total)
You must be logged in to reply to this topic. Login to reply