title: how to do batch insert using R package odbc function dbWriteTable()
body: <p>I have been using dbWriteTable() to save dataframes in R into sql server database for a while.
  Normally, I do as following:</p>
  
  <pre><code>library(odbc)
  con = odbc::dbConnect(odbc(), 
                          Driver = "SQL Server", 
                          Server = server, 
                          Database = "research",
                          Trusted_Connection = "True")
    table = Id(schema = "schemaName", table = "tableName")
    savingResult &lt;- dbWriteTable(con, table, dataframeToSave,append=TRUE,overwrite = FALSE,batch_rows=nrow(dataframeToSave))
  </code></pre>
  
  <p>It works well until recently I am using the same code to save data into a view in the database. This view has a trigger with it. So when you do insert into this view. The trigger will do some checks and save the data into corresponding tables. Basically, I can treat this view as a table. </p>
  
  <p>When I am doing so, my data team staff told me I am not doing a batch insert. I am inserting the data row by row. So if I am inserting a dataframe with 1000 rows, the trigger has been triggered 1000 times. It causes the saving process become very slow.</p>
  
  <p>I thought dbWriteTable() is doing the batch insert all the time. I read from the internet, lost of posts also mentioning that dbWriteTable() is doing the batch insert. My data team staff asked me if this function has a parameter sth similar to FIRE_TRIGGERS. If so, it may solve the issue. However, it seems dbWriteTable() does not have any parameters similar to this one. Does anyone can confirm with if dbWriteTable() is doing a batch insert? If not, is there a way to do the batch insert? </p>
  
  <p>Now I am working around this issue by using dbWriteTable() to write data into a temp table first, then insert the data from the temp table. In this way, the trigger will be only triggered once and the inserting speed is very fast.But I still want to know if there is an easier way to do this without using a temp table.</p>
  
  <p>Thank you.</p>