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)
 Alter Table Syntax

Author  Topic 

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2004-11-07 : 17:58:17
Hi All,

I have a table with columns 'col1','col2','Col3'
Currently All three columns are int type and allows NULL value


Please tell me what will be syntax to modify all three columns to make these NOT NULL and default value 100.

Thanks

mk_garg

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-07 : 18:33:03
alter table mytbl alter column col1 int not null
alter table mytbl add default 100 for col1

repeat for all cols - you'll have to update to remove any nulls first

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2004-11-07 : 19:19:04
Thanks nr

mk_garg
Go to Top of Page

xbcnn
Starting Member

14 Posts

Posted - 2004-11-24 : 20:42:14
Now if I want to drop the default value 100 on one of columns
,What is the SQL script?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-24 : 20:52:20
Use sp_help to find the name of the default then
alter table mytbl drop constraint <defaultname>

have you seen this
http://www.nigelrivett.net/AlterTableProblems.html


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -