Add new column to existing table in sql server 2008

In this post, we will discuss how to add a new column to an existing table in SQL server 2008.

You can also check my previous posts on

A solution for error Saving changes is not permitted sql 2008

WCF tutorial and example in C#.Net

Left outer join and Right outer join in SQL Server.

You can add columns easily to an existing table in the database.

Below is a query which will add a DateTime type column which will not accept a NULL value and put default value as the current DateTime.

Use TestDB
ALTER TABLE Employees
ADD ModifiedDate DateTime NOT NULL DEFAULT(Getdate())
GO

Below is the query that will add a varchar type column to the table which can take NULL values.

Use TestDB
ALTER TABLE Employees
ADD Location varchar(200)null
GO


Check the figure to know about the table structure.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply