In this post we will discuss how we can insert default datetime to a column in sql server 2008 in management studio as well as by using query.
In my previous posts we have discussed about Delete record using enterprise library in Asp.Net [Read here], Add new column to existing table in sql server 2008 [Read here] and WCF tutorial and example in C#.Net.
As we know through the use of GETDATE() function we can get the current date time in SQL server 2008.
Below is the query to add default date value to a column.
CREATE TABLE Employees
EmpId int NOT NULL PRIMARY KEY,
Name varchar(50) NOT NULL,
JoiningDate datetime NOT NULL DEFAULT GETDATE()
Check the below figure to add default value using Management Studio.