BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from...

5
BCP - bulk copy program f or Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server

Transcript of BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from...

Page 1: BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server.

BCP - bulk copy program for Microsoft SQL Server

1

BCP - Bulk Copy Program

Bulk copying to and from Microsoft SQL Server

Page 2: BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server.

BCP - bulk copy program for Microsoft SQL Server

2

BCP introduction

• BCP is use for import and export of data from / to Microsoft SQL Server.

• BCP is a simple(?) command line tool.

• BCP has a lot(!) of options

Page 3: BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server.

BCP - bulk copy program for Microsoft SQL Server

3

BCP import

• Import data from a file to SQL Server.

• Database + tables must exist– no creation at run time

Page 4: BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server.

BCP - bulk copy program for Microsoft SQL Server

4

BCP import example• bcp importexport.dbo.employee in newEmployees.txt -c -t, -UNV14 -Uanders

-Psecret -E

• bcp bulk copy program• importexport.dbo.employee• importexort name of an existing database• dbo database owner (could we write anything else??)• employee name of an existing table (in the importexport

database)• in using bcp to copy data INto the table• newEmployees.txt a text file with the new data• -c the imported file is a text (character) file• - t, field terminator is ","• -SUNV14 server name is "UNV14"• -Uanders user name is "anders"• -Psecret password is "secret"• -E don't ignore the identity columns in the input file• if not new identities are generated

Page 5: BCP - bulk copy program for Microsoft SQL Server 1 BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server.

BCP - bulk copy program for Microsoft SQL Server

5

BCP export example• bcp northwind.dbo.shippers out shipout.txt -c -t, -SUNV14 -Uanders

-Psecret

• bcp bulk copy program• northwind.dbo.shipper• northwind name of database• dbo database owner• shippers name of table• out copying OUT from the database• shipout.txt name of the receiving file• -c output is a text (character) file• - t, field terminator in output file is ","• -SUNV14 server name is "UNV14"• -Uanders username is "anders"• -Psecret password is "secret"