Link to home
Start Free TrialLog in
Avatar of jdr0606
jdr0606Flag for United States of America

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_EndOfDay_Detail
(      
      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
Avatar of RaithZ
RaithZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial