Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BCP HELP PLEASE - RAJEEVNANDANMISHRA

Status
Not open for further replies.

richardmorrison

IS-IT--Management
Jun 20, 2001
9
GB
I WAS WONDERINING IF YOU COULD GIVE ME AN EXAMPLE OF BCP STATEMENT BECAUSE I CAN'T FIND ONE THAT MAKES ANY SENSE.

aLL i WANT TO DO IS SIMPLY PUT THE RESULTS OF A SQL STATEMENT INTO A TEXT FILE OR GRID OF SOME SORT.
 
U can find example of BCP in Books Online of SQL Server. Anyway here is the syntax of BCP comand:

Syntax
bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-m max_errors] [-f format_file] [-e err_file]
[-F first_row] [-L last_row] [-b batch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]
[-q] [-C code_page] [-t field_term] [-r row_term]
[-i input_file] [-o output_file] [-a packet_size]
[-S server_name[\instance_name]] [-U login_id] [-P password]
[-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]

Example:
bcp Management.dbo.Info out c:\Data\info_table.txt -c -q -U"sa" -P""

This example exports the info table from Management database in the c:\Data\info_table.txt file, connecting to the SQL server with sa user name and blanck password.

If u want to use BCP command, this is a system command, and has to be executed in a command proter. U can save the sql statemant results in a view or table and using bcp command export it in a file.
U can put the BCP command in a job and start the job with a T-SQL command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top