|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 4:15 PM
Points: 3,231,
Visits: 64,324
|
|
Duncan Pryde (4/13/2011)
Henrico Bekker (4/12/2011) All 4 options work? one of those questions again...pick 2 out of 4 correct answers...a quessing game again.
Try this: SET DATEFORMAT ydm GO SELECT CAST('2011-04-28' AS DATETIME) or this: SET LANGUAGE British GO SELECT CAST('2011-04-28' AS DATETIME) and do the same for the other date types, and you'll see that DATETIME and SMALLDATETIME produce an error while DATE and DATETIME2 don't. So no guessing required! Duncan
Just look up the various data types in books online.
Only DATE and DATETIME2 have Default String literals... the others do not. And the default string literals are YYYY-MM-DD :)
--Mark Tassin MCITP - SQL Server DBA Proud member of the Anti-RBAR alliance. For help with Performance click this link For tips on how to post your problems
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:30 AM
Points: 861,
Visits: 1,436
|
|
Fortunately I got it right because I somehow knew it'd be a tricky question and I'm studying the new data types in MSSQL 2008. 
But I've never tested them that way and I see a lot of errors when dealing with datetime/smalldatetime conversion to other data types around the internet.
Hoepfully those new date and time types will make our lives easier.
Thank you for the question. :)
Best regards,
Best regards,
Andre Guerreiro Neto
Database Analyst http://www.softplan.com.br MCITPx1/MCTSx2
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 4:27 PM
Points: 432,
Visits: 103
|
|
All 4 work on my SQL 2008. bogus question...
Dennis Parks MCSE, MCDBA, MCSD, MCAD, MCTS
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
Visits: 1,046
|
|
dennisparks (4/19/2011) All 4 work on my SQL 2008. bogus question...
Really?!?!
Try running either SET DATEFORMAT ydm or SET LANGUAGE British
and then see what your results are.
Like someone already pointed out BOL states that DATE and DATETIME2 have Default String literals of YYYY-MM-DD the others do not.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 4:27 PM
Points: 432,
Visits: 103
|
|
I don't remember the question stating to change the default date setting. under default settings, they work fine.
Dennis Parks MCSE, MCDBA, MCSD, MCAD, MCTS
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 3:56 PM
Points: 3,400,
Visits: 3,411
|
|
dennisparks (4/19/2011) I don't remember the question stating to change the default date setting. under default settings, they work fine.
The question clearly stated which ones work 'regardless of any date format or language settings?'.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 4:27 PM
Points: 432,
Visits: 103
|
|
ok, then I guess it tricked me. :~)
Dennis Parks MCSE, MCDBA, MCSD, MCAD, MCTS
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 4:09 AM
Points: 60,
Visits: 175
|
|
| Something is wrong with that answer provided.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 7:27 AM
Points: 1,259,
Visits: 4,260
|
|
Mr Quillz (5/13/2011) Something is wrong with that answer provided.
No, there isn't. Try reading the rest of the thread.
|
|
|
|