8
因此,我想更改SQL Server數據庫中的某列以避免出現空值,但我一直收到錯誤消息。這是我使用的SQL語句:將列更改爲不允許爲空
alter table [dbo].[mydatabase] alter column WeekInt int not null
,這是我得到的錯誤:
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'WeekInt', table 'CustomerRadar.dbo.tblRWCampaignMessages'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
我敢肯定我的SQL是正確的,目前沒有空的列我試圖改變,所以我真的不知道是什麼導致了問題。有任何想法嗎?我很難過。
有錯誤似乎表明您正在運行'INSERT'或'UPDATE'語句,而不是'ALTER TABLE'語句。 –
你是否110%確定該列中沒有任何'nulls',錯誤就表明存在。 –
@a_horse_with_no_name不,這絕對是一個改變腳本 – user2255811