load_df_bcp_f | R Documentation |
This function loads data from an R data.frame into a SQL Server database table by saving the data.frame to an temporary file and then using the BCP (Bulk Copy Program) utility.
load_df_bcp_f(
dataset,
server,
db_name,
schema_name,
table_name,
user = NULL,
pass = NULL
)
dataset |
A data.frame or data.table to be loaded, or a character string specifying the filepath of a text file to be loaded. |
server |
The name of the SQL Server instance. |
db_name |
The name of the target database. |
schema_name |
The name of the schema containing the target table. |
table_name |
The name of the target table. |
user |
Optional. The username for SQL Server authentication. |
pass |
Optional. The password for SQL Server authentication. |
This function uses the BCP utility to efficiently load data into a SQL Server table. It supports both Windows authentication and SQL Server authentication. If a data.frame or data.table is provided, it is first written to a temporary file before being loaded.
Plans for future improvement ...
A character vector containing the output of the BCP command.
Jeremy Whitehurst, 2025-02-05
## Not run:
# Load data from a data.frame
df <- data.frame(id = 1:5, name = c("Alice", "Bob", "Charlie", "David", "Eve"))
load_df_bcp_f(df, "SQLSERVER01", "MyDatabase", "MySchema", "MyTable")
# Load data using SQL Server authentication
load_df_bcp_f(df, "SQLSERVER01", "MyDatabase", "dbo", "MyTable",
user = "myuser", pass = "mypassword")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.