问题描述
- SQL 約束檢查的條件是否可帶參數?
-
check constraint中用參數
檢查中的參數是否可以為查詢,或者是帶參數的自定函授?
multi_company = (select dbo.ls_f_mng_multi_company2(dbo.grn_master.key_seq))
解决方案
解决方案二:
ALTER TABLE grn_master
WITH CHECK ADD CONSTRAINT CK_GRN_MASTER
CHECK (dbo.ls_f_mng_multi_company(KEY_SEQ) = 'Ture')
後提示:訊息 547,層級 16,狀態 0,行 1
The INSERT statement conflicted with the CHECK constraint "CK_GRN_MASTER". The conflict occurred in database "newgar_v1_test", table "dbo.GRN_MASTER", column 'KEY_SEQ'.
The statement has been terminated.
解决方案三:
ALTER TABLE grn_master
WITH CHECK ADD CONSTRAINT CK_GRN_MASTER
CHECK (dbo.ls_f_mng_multi_company(KEY_SEQ) = 'Ture')
後提示:訊息 547,層級 16,狀態 0,行 1
The INSERT statement conflicted with the CHECK constraint "CK_GRN_MASTER". The conflict occurred in database "newgar_v1_test", table "dbo.GRN_MASTER", column 'KEY_SEQ'.
The statement has been terminated.
时间: 2024-11-08 19:49:21