How to modify null column to non nullable column?

0 votes
asked Feb 15, 2016 in T-SQL by khushbu (290 points)

1 Answer

0 votes
answered Feb 16, 2016 by darsh (3,020 points)
selected Feb 16, 2016 by khushbu
 
Best answer

You Can use Alter Table statement

For Example

Alter Table TableA
Alter Column ColA  char(20)  Not NULL

But if your column contain Null value ,first you need to update it from Null to some value.

UPDATE TableA
SET ColA = 'Unknown'
WHERE ColA  IS NULL

After that you can change the column to NOT NULL

 Alter Table TableA
 Alter Column ColA  char(20)  Not NULL
Welcome to I Can Crack, where you can ask questions and receive answers from other members of the community.

68 questions

47 answers

3 comments

5,318 users

...