0

Ask about alter of My SQL SERVER

how can I use alter to change a column from null to not null

29th Mar 2017, 4:25 PM
Phuong Vu
Phuong Vu - avatar
5 Réponses
+ 4
For SQL SERVER 2016, perform following steps 1. Update table values for column in question UPDATE person SET name = 'noname' WHERE name IS NULL; 2. Now alter table definition ALTER TABLE person ALTER COLUMN name VARCHAR(50) NOT NULL;
29th Mar 2017, 4:58 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 3
alter table person modify name varchar (50) not null Please note that for all record said column should have some value, otherwise the statement will fail.
29th Mar 2017, 4:36 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 1
First Step, UPDATE [Table] SET [Column]=0 WHERE [Column] IS NULL Second Step, ALTER TABLE [Table] ALTER COLUMN [Column] INTEGER NOT NULL
29th Mar 2017, 6:39 PM
Ruby C
Ruby C - avatar
0
i cant use modify...with sql server 2016 make erorr
29th Mar 2017, 4:38 PM
Phuong Vu
Phuong Vu - avatar
0
thanks everyone
30th Mar 2017, 5:44 AM
Phuong Vu
Phuong Vu - avatar