I am importing some data from excel to db, the issue is I want to set the specific default value like 00/00/0000 to datetime column when there is no date available from the Excel file.
The getdate() sets the date to current one, but I want to set to a specific date, is it possible to achieve something like this.
Sure you can set a default value – but be aware:
DATETIMEhas a valid range from1/1/1753through12/31/9999– so setting it to0/0/0000will NOT be a validDATETIMEvalue!If you need such a value – use either
DATETIME2in SQL Server 2008 (range is from1/1/0001through12/31/9999) – or useDATE(without any time – same range asDATETIME2)Or: just make your
DATETIME/DATETIME2/DATEcolumn nullable and insertNULLwhen no date is present – that would be the cleanest solution.