90 likes | 386 Views
BCP - Bulk Copy Program. Bulk copying to and from Microsoft SQL Server. 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. BCP import. Import data from a file to SQL Server.
E N D
BCP - Bulk Copy Program Bulk copying to and from Microsoft SQL Server BCP - bulk copy program for Microsoft SQL Server
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 BCP - bulk copy program for Microsoft SQL Server
BCP import • Import data from a file to SQL Server. • Database + tables must exist • no creation at run time BCP - bulk copy program for Microsoft SQL Server
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 BCP - bulk copy program for Microsoft SQL Server
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" BCP - bulk copy program for Microsoft SQL Server