Why write through the linked server, the speed is very slow because when the link server is written, line-by-row write to the database, row by line INSERT, trigger trigger, and so on, write a few lines of data, triggered several triggers, inserted,deleted and other system tables each time only one row of data If the same server is plugged in, a SQL command is bulk inserted, triggering only one trigger, and inserted,deleted will have multiple rows of data test cases: Build tables: CREATE TABLE [dbo]. [Test_batinsert] ([Plucode] [varchar] () NULL, [Scancode] [varchar] (+) NULL) On [PRIMARY] build trigger:CREATE TRIGGER [dbo].Test_batinsert_insert on [dbo]. [Test_batinsert] for INSERT asBEGIN IF UPDATE (Plucode) BEGINIF (Select Len( LTrim(RTrim (Plucode))) from inserted ) > 2--This writing when the isnerted only one row of data, you can execute through, there are multiple rows of data, the syntax is incorrect, will error BEGIN IF IsNumeric ((Select LTrim(RTrim (Plucode)) from inserted )) = 1 BEGIN SELECT 1 END END ENDENDTest Statement Statement 1INSERT Test_batinsert( Plucode,Scancode )SELECT TOP 1 Plucode,Scancode fromTest_batinsert_1 test results, no problem, the inserted statement in the trigger has only one row of data statement 2INSERT Test_batinsert( Plucode,Scancode )SELECT TOP 2 Plucode,Scancode fromTest_batinsert_1 test Result: not normal. Description The inserted statement in the trigger has more than one row of data to execute on another server: statement 1INSERT [Lnkser]. LNKDB.dbo .Test_batinsert( Plucode,Scancode )SELECT TOP 1 Productno,Productno from [test_batinsert_1]Test results, no problem, the inserted statement in the trigger has only one row of data statement 2INSERT[Lnkser]. Lnkdb.dbo .Test_batinsert( Plucode,Scancode )SELECT TOP 2 Productno,Productno fromTest_batinsert_1 test results, no problem, the inserted statement in the trigger has only one row of data conclusion: If you want to exchange data across servers, try to use a linked server for read operations, to avoid write and delete operations.
Why writing through a linked server can be slow