If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > BCP out

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-12, 04:10
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
BCP out

Hi guys,

I need help with bcp out. I have been able to export the data from a table into a .txt file. However the way I did it export the whole columns of the table into a .txt file.
What I want is to export only certain columns, does anyone know how to do this.

This is what I have in my bcp script:

@echo off
bcp TestDB3.dbo.exp_data out "Z:\Export_Data_.txt" -c -t, -T -S Dasasas1T\ABCTEST -U OWNER
pause
Reply With Quote
  #2 (permalink)  
Old 01-24-12, 05:03
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
I cam with this, but is still wrong any ideas?

bcp TestDB3.dbo.EXP_DATA "SELECT COMPANY, CURRENCY, ACCOUNT, AMOUNT, EXTDIM1, EXTDIM2 from EXP_DATA" queryout "Z:\exported.txt" -S servername -U owner -T -c
Reply With Quote
  #3 (permalink)  
Old 01-24-12, 05:34
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
A bit of searching and trying did the stuff what I did was the following:

bcp "SELECT COMPANY, CURRENCY, ACCOUNT, AMOUNT, EXTDIM1, EXTDIM2 from databasename.dbo.EXP_DATA" queryout "Z:\exported.txt" -S servername -U owner -T -c

Last edited by buzmay; 01-24-12 at 08:19.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On