2014/04/15

How to use BCP in & out? (BCP)

To bcp out (get data from DB), please use the below command.

Explanation
GTDMAST1..DISCREPANCY_CD_DTL -> where you want to get the data from
DISCREPANCY_CD_DTL-> the name of the file where you want it to output to
SGTSCOR_UAT510-> server name
UU649121-> username
Pabc123 -> password
-c -t'~^' -r'AAAAABBBBBCCCCC' -b500-> this is the part to separate the data 

Command (OUT):
bcp GTDMAST1..DISCREPANCY_CD_DTL out DISCREPANCY_CD_DTL -SGTSCOR_UAT510 -UU649121 -Pabc123 -c -t'~^' -r'AAAAABBBBBCCCCC' -b500



Explanation
tempdb..DISCREPANCY_CD_DTL -> where you want the data to insert into 
DISCREPANCY_CD_DTL -> the source file
SGTSCOR_DEV510 -> the db server
Usa1 -> username
Pabcd7890 -> passowrd
-c -t'~^' -r'AAAAABBBBBCCCCC' -b500 -> this is the separator and has to be the same with the output command.

Command (IN):
bcp tempdb..DISCREPANCY_CD_DTL in DISCREPANCY_CD_DTL -SGTSCOR_DEV510 -Usa1 -Pabcd7890 -c -t'~^' -r'AAAAABBBBBCCCCC' -b500

No comments:

Post a Comment