Is it possible to perform a bulk insert into an MS-SQL Server (2000, 2005, 2008) using the RODBC package?
I know that I can do this using freebcp, but I'm curious if the RODBC package implements this portion of the Microsoft SQL API and if not, how difficult it would be to implement it.
check out the new odbc
and DBI
packages. DBI::dbWriteTable
writes around 20,000 records per second... Much much faster than the Row Inserts from RODBC::sqlSave()
Now You can use dbBulkCopy
from the new rsqlserver package:
A typical scenario:
dbBulkCopy
to read fil and insert it using internally bcp
tool of MS Sql server.This assume that your table is already created in the data base:
dat <- matrix(round(rnorm(nrow*ncol),nrow,ncol)
id.file = "temp_file.csv"
write.csv(dat,file=id.file,row.names=FALSE)
dbBulkCopy(conn,'NEW_BP_TABLE',value=id.file)
You're probably looking for ?sqlSave
which uses a parametrized INSERT INTO
query (taking place in one operation) when you set Fast=True
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With