Your INSERT T3
without an explicit column list will expect a source of values for the insert that contains a value for every column in the table except IDENTITY
/ROWVERSION
or computed columns.
Your table has a single such column and the SELECT
statement source supplies one column. So the result is that you are inserting an explicit integer value 1
to column DD
.
That column's datatype is datetime
requiring an implicit cast. The result of SELECT CAST(1 AS DATETIME)
is 1900-01-02
hence the results you see.
The legacy datetime
datatypes allow implicit casts from int
and float
and treat the numeric values as days since 1900-01-01
. The newer datatypes such as datetime2
do not support these implicit cast and would raise an error instead.
Default constraint values are only applied when you don't insert an explicit value for that column.
In your case you can do this either by
INSERT T3 DEFAULT VALUES;
Or
INSERT T3 (DD) VALUES (DEFAULT)