I was trying to create a table as follows,
create table table1(date1 datetime,date2 datetime);
First I tried inserting values as below,
Whenever possible one should avoid culture specific date/time literals.
There are some secure formats to provide a date/time as literal:
All examples for 2016-09-15 17:30:00
{ts'2016-09-15 17:30:00'}
--Time Stamp{d'2016-09-15'}
--Date only{t'17:30:00'}
--Time only'2016-09-15T17:30:00'
--be aware of the T
in the middle!'20160915'
--only for pure dateSQL-Server is well know to do things in an order of execution one might not have expected. Your written statement looks like the conversion is done before some type related action takes place, but the engine decides - why ever - to do the conversion in a later step.
Here is a great article explaining this with examples: Rusano.com: "t-sql-functions-do-no-imply-a-certain-order-of-execution" and here is the related question.