OSQL Tab Delimited Text File

  • Hello,

    I've got two problems with this task:

    First, I could get the file to be created in a tab delimited format...the table has 40 columns and on the 40th column instead of a line break (that i wanted) it would insert a TAB. This caused the external program that is importing the text file to fail.

    Second, i've tried changing the arguments to -w -T -S Servername -U SA -P pwd and when that didn't work (it inserted a line break after the 4th column for some reason), I reverted back to the original OSQL and now my text file won't even import cleanly into Access or Excel...there are some extra characters in it that are corrupting it now.

    osql.exe -U SA -P pwd -d HOTEL -S Servername -n -i vsm_his2he.sql -o log.txt

    bcp.exe HOTEL.DBO.hotel_expert_room_registry out "out.txt" -c -T -S Servername -U SA -P pwd

    net use X: /DELETE

    net use X: \\vsmsvr-hexpert\fofile

    xcopy out.txt X:\ /Q /Y

    net use X: /DELETE

    exit

    Does anyone know how to do this right?

  • Have you tried using these switches? \t for tab field terminator and \n for new line row terminator.

    -t"\t" -r"\n"

    HTH



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • thanks, i ended up doing a parameter file and putting in the /n on the last column...

    40 SQLCHAR 0 12 "\r" 40 honor SQL_Latin1_General_CP1_CI_AS

    for some reason it won't show the "backslash n" after the "\r....but i have that in there...

    it works now...but mostly it was the vendors issue that they couldn't import it...

  • How to export sql server data into multiple excel sheets ?

    I don't want to do this from DTS or SSIS. i have dalready done this from OPENROWSET, but only single excel sheet, i want to export data on multiple attached excel sheets on per day bases.

    Pls. any one respond . this is urgent and important for me.

    thanks.

  • { Just realised that this was cross-posted - don't do that!!}

    😀

    Answer moved to new thread that was created here:

    http://www.sqlservercentral.com/Forums/Topic487837-19-1.aspx



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply