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 2008 Forums
 Other SQL Server 2008 Topics
 Unable to change nullable column to non nullable

Author  Topic 

jerill
Starting Member

7 Posts

Posted - 2011-11-02 : 14:42:35
Hi,

I have table called : table1 with 200 rows.

I have Column1 as 1st column which is nvarchar and null. I want to change this column to NOT NULL and make that column1 as primary key. But its not allowing me to do that.

I checked that all values are NOT NULL for Column1.

Still,
alter table table1
alter column column1(nvarchar(50),not null ) is not working ?

Any inputs ?

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-11-02 : 15:20:25
Define 'not working'

--
Gail Shaw
SQL Server MVP
Go to Top of Page

lpozdol
Starting Member

6 Posts

Posted - 2011-11-08 : 17:32:08
do you get an error on alter? Or it runs, but the column still shoes as nullable?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-11-08 : 17:47:40
your syntax was wrong. try this:

alter table table1
alter column column1 nvarchar(50) not null

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -