Solved

set table column default value in management studio

Posted on 2012-04-03
3
608 Views
Last Modified: 2012-04-03
I'm adding a new column to an existing table, and I would like to set a default value for this new added column in SQL server 2005 management studio. How should I set it, and how do I set it graphically? Thanks.
0
Comment
Question by:minglelinch
3 Comments
 
LVL 3

Accepted Solution

by:
Chris__W earned 250 total points
Comment Utility
Hello,

In SSMS for SQL 2005:
Right click on the created table and select Modify.
In the upper pane, click on the Column you wish to add a default for.
In the lower pane, type the default value (or the name of the constraint) into the field labled "Default Value or Binding".
Save and Close the tab.

This will not update existing records without running an Update statement against the records.

-Chris
0
 
LVL 15

Assisted Solution

by:deepakChauhan
deepakChauhan earned 250 total points
Comment Utility
Right click on table and select modify now you have   column name and data types of that table then click on the existing column and look at in lower pane which is column property
in the general block of column property forth option is "default value or binding"
please write a default value whatever you want int he right hand side and finally save the table .

OR  run the script

alter table [dbo].[Table_1] add abc varchar(222)  null constraint def_abc Default(('abc'))
0
 
LVL 1

Author Closing Comment

by:minglelinch
Comment Utility
Thanks a lot.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now