Disable Unicode output

  • I am running SQL Server 2012. I have been producing files as output for the Unix folks at work. We are running into an issue with what appears to be all the files I produce are using Unicode and placing hidden characters in the beginning of files. I am simply using "Results to File" as the option vs going to grid/text.

    The data being exported is not in Unicode data types.

    When viewed in UltraEdit hex mode I see "0" or "EF BB BF".

    The solution I have been using to get around this is taking the file open it in Notepad and do a Save As with Encoding = ANSI from the dropdown.

    Any help on just creating the file in ANSI from the get go would help.

    Thanks.

  • michael_alawneh (7/28/2014)


    I am running SQL Server 2012. I have been producing files as output for the Unix folks at work. We are running into an issue with what appears to be all the files I produce are using Unicode and placing hidden characters in the beginning of files. I am simply using "Results to File" as the option vs going to grid/text.

    The data being exported is not in Unicode data types.

    When viewed in UltraEdit hex mode I see "0" or "EF BB BF".

    The solution I have been using to get around this is taking the file open it in Notepad and do a Save As with Encoding = ANSI from the dropdown.

    Any help on just creating the file in ANSI from the get go would help.

    Thanks.

    Quick thought, use the bcp Utility to export the data.

    😎

  • michael_alawneh (7/28/2014)


    I am running SQL Server 2012. I have been producing files as output for the Unix folks at work. We are running into an issue with what appears to be all the files I produce are using Unicode and placing hidden characters in the beginning of files. I am simply using "Results to File" as the option vs going to grid/text.

    The data being exported is not in Unicode data types.

    When viewed in UltraEdit hex mode I see "0" or "EF BB BF".

    The solution I have been using to get around this is taking the file open it in Notepad and do a Save As with Encoding = ANSI from the dropdown.

    Any help on just creating the file in ANSI from the get go would help.

    Thanks.

    Are you saving it as a .rpt file?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I am saving the results as text (.txt)

    I am running from management studio. For a simple result dump I would think using the bcp would be a little over kill, but I'll give it a go.

    Thanks all.

  • Quick question, the query used for this wouldn't by any chance have a FOR XML statement in it? What you are seeing there is the UTF-8 BOM or Byte Order Mark. The solution could then simply be changing the query, possibly just adding something like .value('.[1]','VARCHAR(MAX)')

    😎

  • None of the queries are XML. Simple selects just outputting as file.

    SET NOCOUNT ON

    SELECT Blah

    , Blah

    FROM dbo.tblBlah

    If it's a default for the UTF-8 format I'm sure there's a place to change it.

  • michael_alawneh (7/29/2014)


    None of the queries are XML. Simple selects just outputting as file.

    SET NOCOUNT ON

    SELECT Blah

    , Blah

    FROM dbo.tblBlah

    If it's a default for the UTF-8 format I'm sure there's a place to change it.

    I cannot recall such a setting, at least it is not in the Query Options.

    I have tried to reproduce this on my server by using combinations of language settings, server collations, column collation etc. but no luck.

    😎

  • You cannot specify a default setting but you can specify the encoding when you generate the results.

    When you run your query the Save Results window has the option. It is a small black triangle which is part of the Save button. This will allow you to specify encoding for your file.

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

Viewing 8 posts - 1 through 7 (of 7 total)

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