This is a trivial question, I added a field
Alter table MyTbl add datecreated smalldatetime default CONVERT(varchar(10),GetDate(),101)
When I go check the new field, it shows not only the date but also time. I check the table definition (right click on table -> Modify in SSMS) and it does say the default value as GETDATE() [it discarded the convert(…) by default]. Why is this so. Is there a way to give a default date only to datetime field and not the time.
I ended up leaving the time field as it is because it is better to see what is going on in the table esp in initial test phase.
I just tried your
ALTERstatement, and it works as you expect; when I enter a row without includingdatecreated, it sets the value to the date with a time of00:00:00.The fact that you checked the table definition and it says the default is
GETDATE()leads me to believe the column already existed and yourALTERfailed.