Home > database >  [the MERGE error] try will not NULL column value is set to NULL
[the MERGE error] try will not NULL column value is set to NULL

Time:09-28

 
The BEGIN TRAN
SELECT * FROM dbo. Ttp_plan_d_9_18100474
DECLARE @ emp VARCHAR (50)='18100474';
DECLARE @ id VARCHAR (10)='8';
The MERGE INTO HMFG. Dbo. Ttp_plan_d AS t
USING dbo. Ttp_plan_d_9_18100474 AS s
ON t.p lnd_id=supachai panitchpakdi lnd_id
The WHEN MATCHED
THEN UPDATE the SET
T.p lnd_date_interval=supachai panitchpakdi lnd_date_interval,
T.p lnd_date_unit=supachai panitchpakdi lnd_date_unit,
T.p lnd_date_num=supachai panitchpakdi lnd_date_num,
T.p lnd_beg_date=supachai panitchpakdi lnd_beg_date,
T.p lnd_end_date=supachai panitchpakdi lnd_end_date,
T.p lnd_time_interval=supachai panitchpakdi lnd_time_interval,
T.p lnd_time_unit=supachai panitchpakdi lnd_time_unit,
T.p lnd_time_num=supachai panitchpakdi lnd_time_num,
T.p lnd_beg_time=supachai panitchpakdi lnd_beg_time,
T.p lnd_end_time=supachai panitchpakdi lnd_end_time,
T.p lnd_duration=supachai panitchpakdi lnd_duration,
T.p lnd_leadtime=supachai panitchpakdi lnd_leadtime,
T.i senable=s.i senable,
T.m odtime=GETDATE (),
T.m oduser=@ emp
WHEN is NOT MATCHED BY TARGET
THEN INSERT
(plnd_plnm_id,
Plnd_date_interval,
Plnd_date_unit,
Plnd_date_num,
Plnd_beg_date,
Plnd_end_date,
Plnd_time_interval,
Plnd_time_unit,
Plnd_time_num,
Plnd_beg_time,
Plnd_end_time,
Plnd_duration,
Plnd_leadtime,
Isenable,
Addtime,
Adduser,
Modtime,
Moduser,
Acctid
)
VALUES (@ id - plnd_plnm_id - int
Supachai panitchpakdi lnd_date_interval - plnd_date_interval - varchar (1)
Supachai panitchpakdi lnd_date_unit - plnd_date_unit - varchar (10)
Supachai panitchpakdi lnd_date_num - plnd_date_num - int
Supachai panitchpakdi lnd_beg_date - plnd_beg_date - a datetime
Supachai panitchpakdi lnd_end_date - plnd_end_date - a datetime
Supachai panitchpakdi lnd_time_interval - plnd_time_interval - tinyint
Supachai panitchpakdi lnd_time_unit - plnd_time_unit - varchar (10)
Supachai panitchpakdi lnd_time_num - plnd_time_num - int
Supachai panitchpakdi lnd_beg_time - plnd_beg_time - a datetime
Supachai panitchpakdi lnd_end_time - plnd_end_time - a datetime
Supachai panitchpakdi lnd_duration - plnd_duration - int
Supachai panitchpakdi lnd_leadtime - plnd_leadtime - int
S.i senable - isenable - tinyint
GETDATE (), - addtime - a datetime
@ emp - adduser - varchar (20)
GETDATE (), - modtime - a datetime
@ emp - moduser - varchar (20)
1 - acctid int
);
DROP TABLE dbo. Ttp_plan_d_9_18100474;
SELECT @ id Code, 'OK' Msg;

The ROLLBACK


Use the merge syntax times wrong,
try will not NULL column value is set to NULL,




But only the four fields inside the original table data is null, and the four fields can be null



and we usually have a field cannot be NULL
Should be the prompt [can't insert the value NULL columns'... ', table '... '; column that allows NULL values]
But now how is so prompt [ try will not NULL column value is set to NULL,


CodePudding user response:

no one encountered this kind of situation

CodePudding user response:

You are opposite, should be the not null field out of the question

CodePudding user response:

refer to the second floor of gypsy song response:
you are opposite, should be the not null field out of the question of

I know, but the source table is two rows of data
Not null field is not null

CodePudding user response:

Since the increase plnd_id and sid two columns?

CodePudding user response:

You shouldn't be in a table to order two on the list, there are two columns without the data, visual is sid is a list of questions

CodePudding user response:

Hello World reference 5 floor, response:
you shouldn't be in the lanes in a table for two on the list, there are two columns without the data, visual is sid is a list of questions

Sid is not on the, have default values
  • Related