bcpExport {bcputility}R Documentation

Export data from SQL Server

Description

A wrapper for a system call to the bcp utility which writes a SQL Server table or query (T-SQL) to a file.

Usage

bcpExport(
  file,
  server,
  database,
  table,
  query,
  trustedconnection = TRUE,
  username,
  password,
  fieldterminator = "\t",
  rowterminator = ifelse(.Platform$OS.type == "windows", "\r\n", "\n"),
  datatypes = c("char", "nchar"),
  ...
)

Arguments

file

output file name

server

the instance of SQL Server to which to connect

database

Specifies the database to connect to

table

name of the source table when exporting from SQL Server

query

Transact-SQL query that returns a result set. Ignored if table is specified.

trustedconnection

use integrated security, username and password are not required

username

login ID

password

password for login ID

fieldterminator

character separator for columns

rowterminator

character separator for rows–new lines

datatypes

the format of datatypes, char performs the operation using a character data type, nchar performs the bulk copy operation using Unicode characters

...

arguments to pass system2

Value

No return value. Operations from bcp are printed to console; see ... to redirect output

Examples

## Not run: 
bcpExport('myfile.tsv',
          server = server,
          database = database,
          table = 'mytable',
          fieldterminator = '|',
          stdout = FALSE,
          datatypes = 'char')

## End(Not run)

[Package bcputility version 0.2.0 Index]