How to Add a Column with Default Value to Existing Table in SQL Server ?

Published on December 11, 2013 by abundantcode

Filed under SQL Server

Last modified December 11, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 3457 times

Looking to add a column with default value to an existing table in SQL Server ? Below is an example and sample Data Definition Language Query for achieving the same.

How to Add a Column with Default Value to Existing Table in SQL Server ?

Assume that the table name is “ACEmployee” which already exists and you want to add a new column called “Status” to the table which is of type integer with the default value of 1. Below is the sample T-SQL for adding the column.

ALTER TABLE ACEmployee
ADD Status int NULL DEFAULT(1)
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

How to Add Comment in XAML and Silverlight?

You can add comment in XAML using the following format<!-- Your Comment -->How to Ad...

How to Configure Default Application Tile of an App in Windows Phone 8 ?

The Windows Phone 8 SDK provides the developers with the option to configure the default tile templa...

How to Get the Maximum value from a List of String using LINQ in C# ?

In one of the previous article , we explained how to get the maximum value from a list of integer us...