Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set Default value?

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
0
0
AU
I need to add a field to an table in sql db that has to have a default value. HOw can I assing the default value to a field in a table please?

Thanks
 
Alter table [blue]table1[/blue]
add [blue]ColumnName[/blue] Integer NOT NULL DEfault [blue]7[/blue]

Alter Table [blue]Table1[/blue]
Add [blue]VarCharColumn[/blue] VarChar([blue]50[/blue]) NOT NULL Default [blue]'George'[/blue]

You will need to change the items in blue.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You can also use EM. Right click on the table and choose Design View. Then select the column and go to the properties window on the bottom of the screen and enter a default value there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top