jdr0606
asked on
Error creating SQL2008 trigger
I'm trying to create a trigger but am getting an error when it runs on the initial create. I actually am simply modifying an existing trigger from another database with much of the same data but no errors.
The error is
Msg 273, Level 16, State 1, Procedure tr_trnUPS_EndOfDay_Insert, Line 13
Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.
The code is
INSERT INTO DYNAMICS_EXT.dbo.trnUPS_En dOfDay_Det ail
(
login_Name
,user_name
,spid
,hostname
,trnAction
,get_date
, OrderNumber
, Weight
, MasterTrackingNumber
, TrackingNumber
, Cost
, DateofShipment
, ShipVia
, CustomerName
, Country
, State
, AccountNumber
, TaxID
, PostalCode
, TS
, Host
)
SELECT
(system_user)login_Name
,(user)user_name
,(@@spid)spid
,(host_name())hostname
,('Insert')trnAction
,(getdate()) as get_date
, OrderNumber
, Weight
, MasterTrackingNumber
, TrackingNumber
, Cost
, DateofShipment
, ShipVia
, CustomerName
, Country
, State
, AccountNumber
, TaxID
, PostalCode
, TS
, Host
FROM INSERTED
The error is
Msg 273, Level 16, State 1, Procedure tr_trnUPS_EndOfDay_Insert,
Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.
The code is
INSERT INTO DYNAMICS_EXT.dbo.trnUPS_En
(
login_Name
,user_name
,spid
,hostname
,trnAction
,get_date
, OrderNumber
, Weight
, MasterTrackingNumber
, TrackingNumber
, Cost
, DateofShipment
, ShipVia
, CustomerName
, Country
, State
, AccountNumber
, TaxID
, PostalCode
, TS
, Host
)
SELECT
(system_user)login_Name
,(user)user_name
,(@@spid)spid
,(host_name())hostname
,('Insert')trnAction
,(getdate()) as get_date
, OrderNumber
, Weight
, MasterTrackingNumber
, TrackingNumber
, Cost
, DateofShipment
, ShipVia
, CustomerName
, Country
, State
, AccountNumber
, TaxID
, PostalCode
, TS
, Host
FROM INSERTED
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.