任何人都可以給出建議。爲什麼我得到這個錯誤。INSERT語句與CHECK約束衝突
System.Data.SqlClient.SqlException:INSERT語句與CHECK約束「CK_ GL10000 _TRXDATE__56701F76」衝突。衝突發生在數據庫「TWO」,表「dbo.GL10000」,列「TRXDATE」中。
這是我的存儲過程:
SqlCommand myCommand1 = new SqlCommand("taGLTransactionHeaderInsert", strcon);
myCommand1.CommandType = CommandType.StoredProcedure;
myCommand1.CommandText = "taGLTransactionHeaderInsert";
myCommand1.Parameters.Add("@I_vBACHNUMB", SqlDbType.Char).Value = GLHdr.BACHNUMB;
myCommand1.Parameters.Add("@I_vREFRENCE", SqlDbType.Char).Value = "ExcelImport";
myCommand1.Parameters.Add("@I_vTRXDATE", SqlDbType.DateTime).Value = GLHdr.TRXDATE;
表定義:
CREATE TABLE [dbo].[GL10000](
[PSTGSTUS] [smallint] NOT NULL,
[LASTUSER] [char](15) NOT NULL,
[LSTDTEDT] [datetime] NOT NULL,
[USWHPSTD] [char](15) NOT NULL,
[TRXTYPE] [smallint] NOT NULL
/* More columns? not included in script that OP added */
)
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[RVRSNGDT])=(0) AND datepart(minute,[RVRSNGDT])=(0)
AND datepart(second,[RVRSNGDT])=(0) AND datepart(millisecond,[RVRSNGDT])=(0)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[Tax_Date])=(0) AND datepart(minute,[Tax_Date])=(0)
AND datepart(second,[Tax_Date])=(0) AND datepart(millisecond,[Tax_Date])=(0)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(day,[TIME1])=(1) AND datepart(month,[TIME1])=(1)
AND datepart(year,[TIME1])=(1900)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[TRXDATE])=(0) AND datepart(minute,[TRXDATE])=(0)
AND datepart(second,[TRXDATE])=(0) AND datepart(millisecond,[TRXDATE])=(0)))
GO
ALTER TABLE [dbo].[GL10000] ADD CONSTRAINT
[DF__GL10000__DEX_ROW__540C7B00] DEFAULT (getutcdate()) FOR [DEX_ROW_TS]
GO
唯一約束? FK約束?你可以發佈嗎? –
讓我知道如何找到哪個約束會引起錯誤。在錯誤描述中,我沒有發現任何約束。 –
使用SQL Mgmt Studio,選擇表GL10000並展開。但是,我的名字是CK_GL10000_TRXDATE__56701F76 –