Exporting bulk data with sql server's bcp utility
Step 1) Open Command Prompt
type C:\> bcp
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
[-d database name] [-K application intent]
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
[-d database name] [-K application intent]
We need bold faced fields to export bulk data into TextFile.
Export Entire table into textfile
bcp ranking out c:\rankings.txt -T -d tempo1 -S .\sqlexpress2012
TableName: ranking
Direction: out
datafile : c:\rankings.txt
T: trusted connection/Windows Authentication
-d: Database Name
-S: Sql Server Instance
Exporting Entire Table into Text file C:\rankings.txt
Export by Query into textfile
bcp "select * from ranking " queryout c:\rankings2.txt -T -d tempo1 -S .\sqlexpress2012
Export Stored Procedure Result into Text File
bcp "exec spranking " queryout c:\rankings2.txt -T -d tempo1 -S .\sqlexpress2012
Tags:
Export by Query into textfile,Export Entire table into textfile,
Export by Query into textfile,Export Entire table into textfile,
Exporting bulk data with sql server's bcp utility,bcp syntax,export data from datatable to textfile
No comments:
Post a Comment