sql - FOR INSERT trigger not firing -


i having problem insert trigger

this trigger code :

set ansi_nulls on go set quoted_identifier on go create trigger [dbo].[vtriggers] on [dbo].[stats] insert insert [newdb].dbo.newstat (statid) select id inserted 

the weird thing , build table exact table want make trigger in , trigger works new 1 , on old 1 not working. info : in old table have multiple inserts in same time.

here schema both table :

old stat ( trigger not working on it)

set ansi_nulls on go  set quoted_identifier on go  create table [dbo].[stats](     [id] [int] identity(1,1) not null,       [code] [nvarchar](100) null,  constraint [pk_stat] primary key clustered  (     [id] asc )with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  =    on, allow_page_locks  = on, fillfactor = 80) on [primary] ) on [primary] textimage_on [primary] 

and new test stat ( trigger works on it) :

set ansi_nulls on go  set quoted_identifier on go  create table [dbo].[teststats](     [id] [int] identity(1,1) not null,       [code] [nvarchar](100) null,  constraint [pk_teststats] primary key clustered  (     [id] asc )with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  =    on, allow_page_locks  = on, fillfactor = 80) on [primary] ) on [primary] textimage_on [primary] 

and here destination table on db :

set ansi_nulls on go  set quoted_identifier on go  create table [dbo].[newstat](     [id] [int] identity(1,1) not null,     [statid] [int] null, ) on [primary]  go 

the trigger works great on test table same schema in old stat table after creating trigger users cant insert in old 1 anymore !

you have wrong insert statement doesn't execute trigger. correct 1 follows.

create trigger [dbo].[vtriggers] on [dbo].[stats] insert insert  [newdb].dbo.newstat         ( statid ) values  ( id ) 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -