1FreeTDS(May 14, 2011)                                    FreeTDS(May 14, 2011)
2
3
4

NAME

6       freebcp - bulk loading utility for Sybase and Microsoft databases
7

SYNOPSIS

9       freebcp [[database.]owner.]object_name {in | [query]out} datafile
10       { -c | -n | -f formatfile }
11       [-b batchsize] [-F firstrow] [-L lastrow] [-e errfile]
12       [-I interfaces] [-m maxerrors] [-t field_term] [-r row_term]
13       [-h hints] [-T textsize] [-A packet_size] [-O options]
14       [-S servername] [-U username] [-P password] [-EdVv]
15

DESCRIPTION

17       freebcp  is a utility program distributed with FreeTDS.  freebcp repli‐
18       cates (in part at least) the functionality of the  "bcp"  utility  pro‐
19       grams distributed by Sybase and Microsoft.
20
21       freebcp  makes  use of the db-lib bcp API provided by FreeTDS. This API
22       is also available to application developers.
23
24       The manual pages or online help for Sybase or SQL Server can be  refer‐
25       enced for more detailed information on "bcp" functionality.
26

TABLES AND FILES

28       database
29              The  database  of  the object being copied.  Optional if the ta‐
30              ble/view is in the default database for username.
31
32       owner  The owner of the object being copied. Optional  if  username  or
33              the database owner is the owner of the table.
34
35       object_name
36              Usually,  object_name is the name of the database table you wish
37              to access. It can also be a view (and, subject  to  constraints,
38              it  is sometimes possible to load a view). It can also be an SQL
39              query, cf. queryout, below.
40
41       in | [query]out
42              The direction of the bulk copy operation.  'in'  indicates  data
43              are  to  be copied from a host file into a database table; 'out'
44              indicates data are to be copied from a database table to a  host
45              file.  'queryout'  indicates that table_name is in fact a query,
46              rather than a database object. freebcp will  execute  the  query
47              and  write the results to a file. (It is a good idea to have the
48              query return one and only one result set.)
49
50       datafile
51              The name of an operating system file.
52

OPTIONS

54       -c     The host data file is (or will be) in "character" format,  i.e.,
55              a  text  file.  Encoding  is  determined  by  the client charset
56              attribute in freetds.conf.
57
58       -n     The host data file is in "native" format.  This is a format that
59              freebcp  will  be  able to process, but is not portable or read‐
60              able.
61
62       -f formatfile
63              The format of the host data file is described by formatfile. The
64              layout  of  formatfile  is  identical  to that understood by the
65              Sybase and Microsoft bcp utilities, but is  too  complicated  to
66              describe here.
67
68       -b batchsize
69              The  number  of  rows per batch of data copied. Batching applies
70              only when you are bulk copying into the database. Each batch  of
71              data  is  effectively 'committed' into the database. The default
72              value for batchsize is 1000.
73
74       -F firstrow
75              The first row to copy from the input file or database table. The
76              default is the first row, row 1.
77
78       -L lastrow
79              The  last row to copy from an input file  or database table. The
80              default is the last row.
81
82       -r row_term
83              The row terminator for a character file.  May be more  than  one
84              character.  Default is newline ('\n'). Cf. -c, above.
85
86       -t field_term
87              The  field terminator for character file. Also known as a column
88              delimiter. May be more  than  one  character.   Default  is  tab
89              ('\t'). Cf. -c, above.
90
91       -m maxerrors
92              Stop after encountering maxerror errors. Default 10.
93
94       -e errfile
95              Write errors to error_file. For uploads.  Includes line and col‐
96              umn information, and the row data.
97
98       -S servername
99              The name of the Database Server to which to connect.
100
101       -U username
102              A database login name. If username is  not  provided,  a  domain
103              login is attempted for TDS 7+ connections.
104
105       -P password
106              A database password.
107
108       -E     Write the data in datafile to the table's IDENTITY column. With‐
109              out this flag, the identity data present in the datafile will be
110              ignored,  and  new  IDENTITY  values  will  be generated for the
111              imported rows.
112
113       -d     Turn off any logging. (Unintuitive, perhaps.)
114
115       -O options
116              SQL text to set connection options prior to the  bcp  operation.
117              If  options  is  a valid filename, the SQL is read from the file
118              instead. Sometimes  needed  for  queryout.   Example:  "-O  'SET
119              QUOTED_IDENTIFIER ON'"
120
121       -I interfaces
122              The name and location of the interfaces file to search when con‐
123              necting to servername. Overrides freetds.conf.
124
125       -h hints
126              Set bcp hints.  For  valid  values,  cf.  bcp_options()  in  the
127              FreeTDS Reference Manual.
128
129       -T textsize
130              For  text or image columns, set the maximum number of characters
131              to  request  from  the  server.  Defaults  to  the  setting   in
132              freetds.conf.  If  not  specified anywhere, defaults to the full
133              size of the data.
134
135       -A packet_size
136              Set the size of a TDS packet to packet_size.  Not sure  why  you
137              would want to do this, except as an experiment.
138
139       -v -V  Print the version information and exit.
140

ENVIRONMENT

142       DSQUERY
143              default servername
144

NOTES

146       When  connecting  to  a Sybase database server, it is required that the
147       TDS 5.0 protocol be used. When connecting to  a  Microsoft  SQL  Server
148       2000 database server, the TDS 7.1 protocol is required.
149
150       Theoretically  both  Sybase and Microsoft support the TDS 4.2 protocol,
151       but in reality they implement the bcp portion of TDS  4.2  differently.
152       FreeTDS  has  no way of knowing which type of server it's connected to,
153       hence TDS protocol 4.2 is not supported.
154

HISTORY

156       freebcp first appeared in FreeTDS 0.60
157

AUTHORS

159       The  freebcp   utility   was   written   by   Bill   Thompson   (thomp‐
160       bil@exchange.uk.ml.com)
161

BUGS

163       Currently, there is no support for text data types in freebcp, when SQL
164       Server 2000 is the target database.
165
166
167
168FreeTDS Utilities                   0.91RC2              FreeTDS(May 14, 2011)
Impressum