Exporting data problem (Unicode or collation issue?)

  • I'm new to sql 2005 and having dfficulty with a simple task - outputng a view to a text file. When I export using either bcp or "Results to text file" I get an output where every charecter is separated by a non valid char (which appears as a block in notepad).

    i.e.

    |R|e|s|u|l|t|s| |l|o|o|k| |l|i|k|e| |t|h|i|s|

    (but with a block charecter rather than pipe)

    My first thought was this could be a unicode problem which may explain the extra none ascii chars that are being output. But then again, all columns are varchar rather then nvarchar so I thought this shouldn't be problem.

    Could it be a colation issue, and if so, how can I get the query to export properly round without changng the collation on the table?

    Strangely, when I create a DTS package in SQL2000 and use the sql2005 server as the source, it exports ok.

  • What is your bcp command? What does it look like in Wordpad?


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

  • The bcp command was:

    bcp CPPhil.dbo.vwInput_Client_YO1 out Client_YO1.dat -n -t, -q -SLYRA\SQL2005 -T

    i.e. native type; field terminator=comma; quoted identifies; trusted connection

    When I open it in Wordpad the formatting is even worse. Garbled mess like the following...

    ïYesOut01_ClientDetailTEST,,ùL,ÿ,ÿ,;—,Âð,Mr ,H , Levitt

     

  • Add the -c switch to your command line so that it copies out the data as character data.

     

    bcp CPPhil.dbo.vwInput_Client_YO1 out Client_YO1.dat -n -c -t, -q -SLYRA\SQL2005 -T


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

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

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