June 18, 2013 at 8:45 pm
Comments posted to this topic are about the item SQL CHOOSE
--------
For SQL Tips, check out my blog: http://lantztechknowledge.blogspot.com/[/url]
You can also follow my twitter account to get daily updates: @BLantz2455
June 18, 2013 at 8:58 pm
Good one, thank you for posting.
(Or, the date '1931-02-29' if the year is not leap)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
June 18, 2013 at 10:59 pm
Good question.. "CHOOSE" new built-in-function in SQL 2012.
June 18, 2013 at 11:08 pm
Good question. But i think this question should had topic "DateTime" rather than "SQL CHOOSE". 🙂
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
June 19, 2013 at 12:34 am
Thanks for the question.
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
June 19, 2013 at 12:54 am
Thanks for the question...
Learn about CHOOSE today 🙂
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 19, 2013 at 1:09 am
If the statement begins with
set dateformat ymd
,
the qotd would be perfect.
June 19, 2013 at 2:14 am
Danny Ocean (6/18/2013)
Good question. But i think this question should had topic "DateTime" rather than "SQL CHOOSE". 🙂
based on the explanation, I guess, you reached the conclusion. The reference reach out to Choose(T-SQL) which is nowhere mentioned in the explanation.
Easy question though.
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
June 19, 2013 at 2:20 am
I ran the code and got:
Msg 242, Level 16, State 3, Line 7
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.
That was in the INSERT rather than the SELECT though.
June 19, 2013 at 2:29 am
Richard Warr (6/19/2013)
I ran the code and got:
Msg 242, Level 16, State 3, Line 7
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.
That was in the INSERT rather than the SELECT though.
Re-run the code with "set dateformat ymd" first
June 19, 2013 at 3:04 am
Carlo Romagnano (6/19/2013)
Richard Warr (6/19/2013)
I ran the code and got:
Msg 242, Level 16, State 3, Line 7
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.
That was in the INSERT rather than the SELECT though.
Re-run the code with "set dateformat ymd" first
1+
other wise remove datetime
create table #Employee
(
PositionId int,
Birthday date
)
insert into #Employee
select 0, '1995-01-01'
union all
select 1, '1983-08-01'
union all
select 2, '1948-07-31'
union all
select 3, '1932-02-29'
union all
select 4, '1980-06-15'
--Query 1
SELECT BirthMonth = CHOOSE (Month(Birthday), 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
FROM #Employee
drop table #Employee
Malleswarareddy
I.T.Analyst
MCITP(70-451)
June 19, 2013 at 3:21 am
It is all very well saying "re-run it with this additional line" when the returned error from the code in the question is exactly the wording of one of the wrong answers, but doesn't this just prove that as the question was framed - excluding the date format specification that both 2 and 3 were correct answers?
June 19, 2013 at 3:29 am
matthew.flower (6/19/2013)
It is all very well saying "re-run it with this additional line" when the returned error from the code in the question is exactly the wording of one of the wrong answers, but doesn't this just prove that as the question was framed - excluding the date format specification that both 2 and 3 were correct answers?
That's correct, but the qotd was about CHOOSE and not date formats.
The installation takes as default for the date format the regional settings. For e.g. in Italy it is dmy, in U.S.A is ymd, In England ydm and so on.
June 19, 2013 at 3:42 am
Nice function, didn't remember that one coming in. I'd argue that maybe for some cases CASE might still be a little clearer, if more unwieldy, but options are always good.
June 19, 2013 at 3:58 am
This was removed by the editor as SPAM
Viewing 15 posts - 1 through 15 (of 36 total)
You must be logged in to reply to this topic. Login to reply