[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

set table column default value in management studio

Posted on 2012-04-03
3
Medium Priority
?
656 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 1000 total points
ID: 37802253
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 16

Assisted Solution

by:Deepak Chauhan
Deepak Chauhan earned 1000 total points
ID: 37802408
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
ID: 37803585
Thanks a lot.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

872 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