Resources » .NET programming » Databases

BCP Utility


Posted Date: 04-Mar-2009  Last Updated:   Category: Databases    
Author: Member Level: Silver    Points: 20



BCP utility in Sql Server

BCP is an acronym for Bulk Copy Program. It is a command-line utility of Sql Server. With the help of BCP we can export data from database table to flat files, from results of database queries to flat files and we can import the data from flat files to database tables.

Syntax: bcp {[[database_name.][owner].]database table or view | “query”}{in|out|queryout|format} data_file [-r row_terminator] [-t field_terminator] [-S server_name[\instance_name]] [-U login_id] [-P password] [-T]

in - when copying data into sql server database table or view from file.
out - when copying data from sql server database table or view to file.

-r - Row terminator . The default it \n
-t -Field terminator . The default it \t

-S - Specify the server name to connect to the default instance of Sql Server on that server.
-U - Specify the login id to connect to Sql Server.
-P - Specify the password to connect to Sql Server.
-T - For trusted Connection.

Examples:
bcp leaves.dbo.leaves out f:/leaves.txt -n -Ssystem109 -Usa -Psa1

It copies the data from leaves table to leaves.txt file.

bcp sampledb.dbo.leaves1 in f:/leaves.txt -n -Ssystem109 -Usa -Psa1

It copies the data from leaves.txt file to leaves1 table.

-n is used to use the native data types of the data. (If it was not mentioned system prompts for the data types of each field).


Did you like this resource? Share it with your friends and show your love!

Responses to "BCP Utility"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India