Change a column to not allow nulls

后端 未结 2 553
悲&欢浪女
悲&欢浪女 2021-01-04 06:59

So I want to change a column in my SQL Server database to not allow nulls, but I keep getting an error. this is the sql statement I am using:

alter table [db         


        
2条回答
  •  执念已碎
    2021-01-04 07:49

    If you are trying to change a column to not null, and you are getting this error message, yet it appears the column has no nulls, ensure you are checking for is null and not = null (which gives different results).

    Select * from ... where column is null
    

    instead of

    Select * from ... where column = null
    

    I am adding this because it tripped me up and took a while to resolve.

提交回复
热议问题