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)
 constraints

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-24 : 08:26:49
subbareddy writes "How to add existing columns not null constraint..

Example ..
Create table test(no int)
i need not null constraint in no..
how to add"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-03-24 : 08:45:00
alter table mytbl add mycol int not null default 1
see
http://www.nigelrivett.net/SQLAdmin/AlterTableProblems.html
for some problems it can cause

==========================================
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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-24 : 09:54:15
To alter existing column, use

Alter table test alter column no int not null

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -