0

I am trying to figure out a way to speed up this query...as is it takes about 40 minutes.

Inserts new rows not existing in a table of a linked server.

        INSERT INTO [remote.server.com].[DB].dbo.Table1( Id , Barcode , Name , Address , Address2 , City , State , Zip , Date , Text1 , Text2 , Text3 , Text4 , Text5 , Text6 , Text7 , Text8 , Text9 , Text10 ) 
        SELECT s.Id , s.Barcode , s.Name , s.Address , s.Address2 , s.City , s.State , s.Zip , s.Date , s.Text1 , s.Text2 , s.Text3 , s.Text4 , s.Text5 , s.Text6 , s.Text7 , s.Text8 , s.Text9 , s.Text10
          FROM LocalTable1 AS s LEFT OUTER JOIN [remote.server.com].[DB].dbo.Table1 AS d ON s.Id = d.Id AND s.Barcode = d.Barcode
          WHERE d.Id IS NULL;

Any ideas? Thanks for the help.

sds
  • 61
  • 7
  • If you have index on ID an BarCode here is nothing to improve. – Giorgi Nakeuri Jun 05 '15 at 15:32
  • I do. Maybe i should ask this instead - what are the best options for syncing table data from local to remote server, where remote server table may contain additional data i don't want removed in the sync? Also, this would need to be in a fashion that could be automated via sql job? – sds Jun 05 '15 at 15:56
  • you are looking for Replication – Giorgi Nakeuri Jun 05 '15 at 16:04
  • Replication won't delete rows from destination that don't exist in source? The destination table (remote) has additional rows that i don't want to be removed. – sds Jun 05 '15 at 16:05
  • why it would delete? There is several types of replication and you can configure as you want. – Giorgi Nakeuri Jun 05 '15 at 16:12

0 Answers0