Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Adding a default value to an exiting column

Author  Topic 

Drobson2
Starting Member

6 Posts

Posted - 2005-07-18 : 12:45:39
Hello all,

I'm having trouble generating the correct Alter table statement which will allow me to and both a Not Null and a default of 5 to an integer column

I started out with:

Alter Table invoice alter invoice_charge_category_id int not null default 5

but this is wrong. Looking at the help, it looks like I can't add a default to an existing column - or at least that's where I'm having trouble.

Thanks for your help!!
Dave

Drobson2
Starting Member

6 Posts

Posted - 2005-07-18 : 13:26:28
Never mind! I found it!
alter table <tbl name> add constraint <cnstrnt named> default <value> for <column name>
Go to Top of Page
   

- Advertisement -