How bcp command prompt utility is used to import and export data

Describe how bcp command prompt utility is used to import and export data.

The bcp utility is accessed from the command prompt.

Syntax:
bcp {dbtable | query} {in | out | queryout | format} datafile [-n native type] [-c character type] [-S server name] [-U username] [-P password] [-T trusted connection]

It starts with specifying the database or object name. In and out means whether the data needs to be copied into or out of the database. Hence in will be used for importing data while out will be used to export data. Remaining arguments are the basic command line arguments.

Example1: import data of Company database to the employee table
bcp Company.dbo.employee in c:\temp\employee.bcp -c -Sstevenw -Usa –P

Example2: Export data of Company database from the employee table
bcp Company.dbo.employee out c:\temp\employee.bcp
Describe how bulk insert statement is used to import data
Bulk Insert is used to copy data from a file into a table or view in a format as specified by the user........
Define distributed queries
Distributed queries access data from multiple heterogeneous sources. These data sources may or may not be stored on the same computer........
How Linked server is used to excess external data
A linked server can be considered as another SQL server database running elsewhere. It can be a OLEDB or ODBC data source......
Post your comment