Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Disable Unicode output Expand / Collapse
Author
Message
Posted Monday, July 28, 2014 5:15 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 8:44 AM
Points: 7, Visits: 76
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.
Post #1597119
Posted Monday, July 28, 2014 9:38 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 2,543, Visits: 7,147
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.
Post #1597144
Posted Tuesday, July 29, 2014 8:09 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:47 PM
Points: 35,808, Visits: 32,480
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1597553
Posted Tuesday, July 29, 2014 8:46 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 8:44 AM
Points: 7, Visits: 76
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.
Post #1597558
Posted Tuesday, July 29, 2014 9:59 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 2,543, Visits: 7,147
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)')
Post #1597567
Posted Tuesday, July 29, 2014 10:14 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 8:44 AM
Points: 7, Visits: 76
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.
Post #1597569
Posted Tuesday, July 29, 2014 10:33 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 2,543, Visits: 7,147
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.

Post #1597571
Posted Wednesday, July 30, 2014 6:24 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 1:44 AM
Points: 1,001, Visits: 3,091
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

@SeanPearceSQL

About Me


  Post Attachments 
SSMSSave.png (25 views, 5.25 KB)
Post #1597681
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse