title: How to upload multiple csv files to a SQL server Database using R
body: <p>I have a number folders that store &gt;50 different csv files in each folder, each with different names, different number of variables, and lengths. I have to upload them to a SQL server (SSMS) and instead of having to upload them one by one I would like to ask how to batch upload them all at once, <em>especially</em> their unique names (i.e. Demographics, Biologic, Sites, Labs, OthLabs, Subjects, etc.) and they are not big (under 5mb per folder). I've tried creating a list <code>csv &lt;- dir(pattern = &quot;csv&quot;)</code> but haven't figured out how to use it with <code>DBI::dbWriteTable(conn = con, name = , value = , overwrite = FALSE)</code> . I would be very grateful if someone has dealt with this in the past could help me.</p>
  <p><strong>Update</strong></p>
  <p>the tables in question are all different, having different dimensions and lengths (i.e.(130,12), (151,33), (1,6), (603, 16), etc.), what i'm trying to do is to upload them with their names. I've tried the code bellow</p>
  <pre><code>alldat &lt;- lapply(csv, read.csv) 
  for (i in alldat) {
  dbWriteTable(conn = con,
   name = &quot;i&quot;,
   value =  i,
   overwrite = FALSE)
    }
  </code></pre>
  <p>yes it works, but will create only 1 table called &quot;i&quot;, any recommendation on what should  the arguments for <code>name = </code> and <code>value = </code> be so that the loop will continue copying the tables from R to SQL server with the table names?</p>
  <p>other functions that I've tried unsuccessfully are <code>list2env</code>, <code>assign</code> <code>do.call(rbind, i)</code></p>