{}

Our Brands

Welcome to the Schneider Electric Website

Welcome to our website.
How can we help you today?
How to Extract Data from a Database Using a Command Prompt
Issue
Exporting data from a table in database.

Product Line
BCP (Bulk Copy Program)

Environment
Command prompt window

Cause
Sometimes the customer may not be tech-savvy and it is easier to extract the required information by passing a command and asking them to run it from a DOS window.

Resolution
BCP is a utility that can be executed from the command line and has the following syntax:
bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-mmax_errors] [-fformat_file] [-x] [-eerr_file]
[-Ffirst_row] [-Llast_row] [-bbatch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70 | 80)] [-6]
[-q] [-C { ACP | OEM | RAW | code_page } ] [-tfield_term]
[-rrow_term] [-iinput_file] [-ooutput_file] [-apacket_size]
[-Sserver_name[\instance_name]] [-Ulogin_id] [-Ppassword]
[-T] [-v] [-R] [-k] [-E] [-h"hint [,...n]"]

Here is an example of how to extract data from 'Source' table in ION_Data:

C:\>BCP "select * from ion_data.dbo.source" queryout C:\Temp\SourceNames.txt -SCB9RBM313\ION -w -T

Where:
–S:  specifies the instance name to connect to
-w:  performs copy operation using Unicode characters
–T:  designates a trusted connection and BCP uses the Windows credentials; In case there is no Windows credentials, –U (specifies the login name) and –P (specifies the password) can be used instead.
queryout:  copies from a query and must be specified only when bulk copying data from a query

A text file is created in the specified destination.

Command Window


Here is how the data is formatted in the text file:

Output file

Schneider Electric Canada

How to Extract Data from a Database Using a Command Prompt
Issue
Exporting data from a table in database.

Product Line
BCP (Bulk Copy Program)

Environment
Command prompt window

Cause
Sometimes the customer may not be tech-savvy and it is easier to extract the required information by passing a command and asking them to run it from a DOS window.

Resolution
BCP is a utility that can be executed from the command line and has the following syntax:
 
bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-mmax_errors] [-fformat_file] [-x] [-eerr_file]
[-Ffirst_row] [-Llast_row] [-bbatch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70 | 80)] [-6]
[-q] [-C { ACP | OEM | RAW | code_page } ] [-tfield_term]
[-rrow_term] [-iinput_file] [-ooutput_file] [-apacket_size]
[-Sserver_name[\instance_name]] [-Ulogin_id] [-Ppassword]
[-T] [-v] [-R] [-k] [-E] [-h"hint [,...n]"]

Here is an example of how to extract data from 'Source' table in ION_Data:

C:\>BCP "select * from ion_data.dbo.source" queryout C:\Temp\SourceNames.txt -SCB9RBM313\ION -w -T

Where:
–S:  specifies the instance name to connect to
-w:  performs copy operation using Unicode characters
–T:  designates a trusted connection and BCP uses the Windows credentials; In case there is no Windows credentials, –U (specifies the login name) and –P (specifies the password) can be used instead.
queryout:  copies from a query and must be specified only when bulk copying data from a query

A text file is created in the specified destination.

Command Window


Here is how the data is formatted in the text file:

Output file

 

Schneider Electric Canada

Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.
Users group

Discuss this topic with experts

Visit our community and get advice from experts and peers on this topic and more
move-arrow-top
Your browser is out of date and has known security issues.

It also may not display all features of this website or other websites.

Please upgrade your browser to access all of the features of this website.

Latest version for Google Chrome, Mozilla Firefox or Microsoft Edgeis recommended for optimal functionality.
Your browser is out of date and has known security issues.

It also may not display all features of this website or other websites.

Please upgrade your browser to access all of the features of this website.

Latest version for Google Chrome, Mozilla Firefox or Microsoft Edgeis recommended for optimal functionality.