A wrapper for a system call to the bcp utility which writes a SQL Server table or query (T-SQL) to a file.
bcpExport(
file,
connectargs,
table,
query,
fieldterminator = "\t",
rowterminator = ifelse(.Platform$OS.type == "windows", "\r\n", "\n"),
bcpOptions = list("-c", "-b", 1000, "-a", 4096, "-m", 10),
...
)
No return value. Operations from bcp are printed to console; see
...
to redirect output
output file name
named list of connection arguments. See makeConnectArgs.
name of the source table when exporting from SQL Server
Transact-SQL query that returns a result set. Ignored if table is specified.
character separator for columns
character separator for rows--new lines
list of additional options to pass to the bcp
utility. See details.
arguments to pass system2
The bcpOptions
allows the user to include additional arguments for the
call to system2
. Please refer to
https://learn.microsoft.com/en-us/sql/tools/bcp-utility.
The default options are set
to the defaults for bcp
CLI. -b
refers to
number of rows to write at a time; 10,000 to 50,000 is a
starting recommendation. -a
refers to size of packets to be sent in
bytes. -e
refers to the maximum number of errors before failure.