after insert trigger not firing after inserting with bcp
-1
votes
3
answers
946
views
content of csv file
TEST_1|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 0, 'a1': 0, 'a2': 0, 'a3': 0, 'event': 5528, 'event_string': 'ENERGY_CTRL_RIGHT_PROX_DOWN', 'history_buffer_id': 3, 'history_buffer_string': 'HISTORY_BUFFER_UI_EVT', 'mid': 10, 'mid_string': 'CONSOLE1'}}|2021-06-26 05:03:20|
TEST_11|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 393280, 'a1': 1, 'a2': 0, 'a3': 0, 'event': 8316, 'event_string': 'BP_FOLLOW_CHECK', 'history_buffer_id': 0, 'history_buffer_string': 'HISTORY_BUFFER_BP', 'mid': 6, 'mid_string': 'MTMR'}}|2021-06-26 05:03:20|
TEST_2|sl2sysxbar301.dv.local|{'message_type': 4, 'mmdsp_log': {'bp_start': {'bp_arg': 0.0, 'bp_code': 4097, 'bp_sn': 393300, 'mid': 6}, 'legacy_log_idx': 0}}|2021-06-26 05:03:20|
TEST_4|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 267, 'a1': 0, 'a2': 0, 'a3': 0, 'event': 100001, 'event_string': 'INTER_MANIP', 'history_buffer_id': 3, 'history_buffer_string': 'HISTORY_BUFFER_UI_EVT', 'mid': 1, 'mid_string': 'AIM2'}}|2021-06-26 05:03:20|
here is bcp running via python
p = subprocess.Popen(
f'/opt/mssql-tools/bin/bcp {app.config.db_table_name} in {f.get("filename")} -S {app.config.db_host},{app.config.db_port} -U {app.config.db_username} -P {app.config.db_password} -t "|" -c',
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
I have this table and trigger
CREATE TABLE [EVT_STREAM].[Event](
[SystemName] [varchar](25) NOT NULL,
[Router] [varchar](128) NULL,
[Event] [nvarchar](max) NULL,
[ReceivedAt] [datetime] NOT NULL,
[InsertedAt] [datetime] NULL
)ON [PRIMARY]
GO
CREATE TRIGGER [EVT_STREAM].[trg_EVT_STREAM]
ON [EVT_STREAM].[Event]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON;
insert into [EVT_STREAM].[Event](
[InsertedAt]
)
VALUES(
GETUTCDATE()
)
END
GO
ALTER TABLE [EVT_STREAM].[Event] ENABLE TRIGGER [trg_EVT_STREAM]
GO
basically I would like to update [InsertedAt]
at the time when BCP runs and inserts CSV records in [EVT_STREAM].[Event] table.
Asked by vector8188
(109 rep)
Jun 26, 2021, 05:18 AM
Last activity: Jun 27, 2021, 09:50 PM
Last activity: Jun 27, 2021, 09:50 PM