Bulk insert is not bringing in typical control characters correctly.

  • I have exported data from a Sybase SQL Anywhere db table. Which I can successfully import into a SS2K5 db.

    However in the varchar(fields the the control characters for Carriage return, line feed and Tab are not coming through as expected. Instead the column values includes the strings '\x0D', '\x0A' and '\x09' and are not interpreted as expected when displayed or printed.

    Example:

    In the legacy app/db a string may appear as:

    "...... capital spares.

    Justified by......"

    In Sybase side, export code looks like this:

    Select * from DBA."Projects" ;

    OUTPUT TO 'E:\tw\KMCA\scripts\SQL Server\Data\Projects_Export.DAT' FORMAT ASCII DELIMITED BY '\x09' QUOTE '' ;

    exported data looks like so:

    "...... capital spares.\x0D\x0DJustified by......"

    BULK INSERT projects from 'C:\E_drive\tw\KMCA\scripts\SQL Server\Data\Projects_Export.DAT'

    WITH ( KEEPIDENTITY , FIELDTERMINATOR = '\t' , ROWTERMINATOR ='', MAXERRORS = 100 ) ;

    In the SS2K5 side import is handled like so:

    BULK INSERT dbo.projects from 'C:\E_drive\tw\KMCA\scripts\SQL Server\Data\Projects_Export.DAT'

    WITH ( KEEPIDENTITY , FIELDTERMINATOR = '\t' , ROWTERMINATOR ='', MAXERRORS = 100 ) ;

    When printed or displayed by the app the string appears just like it does in the DAT file:

    "...... capital spares.\x0D\x0DJustified by......"

    It think the export is coded okay, so it must be something in my bulk insert.

    Any helps for me?

    Thanks in advance,

    Joel

    Takauma

  • The exported code is the culprit \x0D in character format won't be interpreted by SQL Server as as CR. You need actual CR exported.


    * Noel

  • There don't seem to be any other export options. Every format I try except XML exports the controls codes as text.

    Takauma

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

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