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
 General SQL Server Forums
 New to SQL Server Programming
 alter column to not null

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-03-19 : 04:32:47
hi team ,

i need to alter a column to not null
but when i run the below query


ALTER TABLE TESTDATA1
ALTER COLUMN istatus DECIMAL(10,0) NOT NULL

i throws an error that some index is dependent on istatus.

please help

challenge everything

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-19 : 04:33:48
1. Drop the index
2. Update the column to the default value for the NULL rows
3. ALTER TABLE to NOT NULL
4. Create the index



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -