0

I like to insert Multiple records (bulk insert) in MS SQL CE. I can access my CE (*.sdf) database via VS 2010 studio.

I googled and found the link below for the bulk insert syntax. Inserting multiple rows in a single SQL query?

I prepared following syntax (just showing 3 records now) :

INSERT INTO CompteGenerals

(Company, LineId, Account, Description1, Description2)

VALUES (999999, 1, N'4000', N'Clients', N'Klanten')

,VALUES (999999, 2, N'4400', N'Fournisseurs', N'Leveranciers')

,VALUES (999999, 3, N'4510', N'TVA à payer', N'Verschuldigde BTW')

but how can I insert my bulk records? (since the SQL CE database is re-created regularly (development), I don't want to add all records manually)

please advice.

Community
  • 1
  • 1
ethem
  • 2,888
  • 9
  • 42
  • 57
  • Does this answer your question? [SQL Server CE Insert multiple rows](https://stackoverflow.com/questions/51569743/sql-server-ce-insert-multiple-rows) – shashwat May 24 '21 at 17:02

1 Answers1

2

That syntax is not supported with SQL Server Compact. But you can bypass the Query processor to do very fast INSERTs, my SqlCeBulkCopy library simplifies that, available at http://sqlcebulkcopy.codeplex.com

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • I added the package "ErikEJ.SqlCe40" in my project, do you have a sample or quick run things, so I can test start immediately, rather than reading the whole pages at first... I mean will read and see the possibilities, since I use SQLCE, but I like to insert asap the records. pelase advice? I'm using EF code first and Linq in my project – ethem Mar 26 '13 at 10:11
  • Sample code here: http://sqlcebulkcopy.codeplex.com/ Supply a list of objects or a DataTable or DbDataReader – ErikEJ Mar 26 '13 at 10:34