SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Unicode output from varchar data columns


Unicode output from varchar data columns

Author
Message
jk_in_San_Diego
jk_in_San_Diego
SSC Veteran
SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)

Group: General Forum Members
Points: 226 Visits: 71
This is a bit odd - I have a table in SQl Server 2005 Standard Edition defined like so:

CREATE TABLE [dbo].[RuleInput](
[SiteID] [varchar](9) NULL,
[ConID] [varchar](6) NULL,
[Email] [varchar](50) NULL,
[First] [varchar](400) NULL,
[Middle] [varchar](400) NULL,
[Last] [varchar](400) NULL,
[Language] [varchar](3) NULL,
[Source] [varchar](3) NOT NULL,
[Domain] [varchar](400) NULL,
[RuleID] [int] NOT NULL
) ON [PRIMARY]
END

I fill this table with data, no problems there.

Now I wish to send the output of the following query to a file:

SELECT R.[SiteID]
,R.[ConID]
,'' AS [Prefix]
,RTRIM(R.[First]) AS [First]
,RTRIM(R.[Middle]) AS Middle
,RTRIM(R.[Last]) AS [Last]

,RTRIM(R.[Email]) AS [Email]
,RTRIM(R.[Domain]) AS [Domain]
,[Source]
,[RuleID]
,R.[Language]
FROM [EmailWork].[dbo].[RuleInput] R

Using the "Results to File" toolbar item after setting the Query > Query Options like so:
Advanced tab: check the "Set Nocount" box
Text tab: Custom Delimiter - Pipe symbol, and uncheck the "Include column headers in result set" box

Here's my problem - the output file contains UNICODE for all of the text fields.

Collation for my database is: SQL_Latin1_General_CP1_CI_AS

Is there something I can do to set my default to ASCII?

Thanks in advance for any insight/help on this issue.

/john
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34163 Visits: 13270
I don't know if this is a one shot (if it is, you can simply convert to ASCII with the free tool Notepad++), but if it isn't, you can use SSIS or bcp to extract the data to an ASCII text file.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
jk_in_San_Diego
jk_in_San_Diego
SSC Veteran
SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)

Group: General Forum Members
Points: 226 Visits: 71
Thanks for the reply. I used an SSIS package to output the file as ASCII text to meet my immediate need.

I would like to know if it's possible to change a database or table setting (or login setting?) to allow the Results to File query option to send the ASCII text properly rather than defaulting all text output to Unicode text.

Having to write a quicky SSIS package every time I want to generate file output from a table is not a big deal, but it sure seems like a waste.

/john
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34163 Visits: 13270
jk_in_San_Diego (7/25/2013)
Thanks for the reply. I used an SSIS package to output the file as ASCII text to meet my immediate need.

I would like to know if it's possible to change a database or table setting (or login setting?) to allow the Results to File query option to send the ASCII text properly rather than defaulting all text output to Unicode text.

Having to write a quicky SSIS package every time I want to generate file output from a table is not a big deal, but it sure seems like a waste.

/john


I digged around for a bit, but could't really find a solutin within SSMS itself.
Like I said, you can quickly convert the file to ASCII with Notepad++. Just a few clicks.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
jk_in_San_Diego
jk_in_San_Diego
SSC Veteran
SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)

Group: General Forum Members
Points: 226 Visits: 71
Yeah, I know and love Notepad++ myself, but it is limited on the maximum file size that it can handle. Unfortunately, some of my text output files get up into the 6+ GB size.

/john
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34163 Visits: 13270
jk_in_San_Diego (7/25/2013)
Yeah, I know and love Notepad++ myself, but it is limited on the maximum file size that it can handle. Unfortunately, some of my text output files get up into the 6+ GB size.

/john


Ah, that might be an issue :-)


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
jk_in_San_Diego
jk_in_San_Diego
SSC Veteran
SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)

Group: General Forum Members
Points: 226 Visits: 71
File this under "you learn something new every day" - my coworker (Linda Knott - The Magnificent!) reminded me that the Save button during the file name prompt has a down-arrow. Clicking the down-arrow allows you to select "Save with encoding..." which allows you to choose Unicode (the default), ANSI (which is ASCII), or Chineese characters.

Huzza! Select the correct encoding for the type of file you want to output and voila! It's a done deal.

/john
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34163 Visits: 13270
jk_in_San_Diego (7/25/2013)
File this under "you learn something new every day" - my coworker (Linda Knott - The Magnificent!) reminded me that the Save button during the file name prompt has a down-arrow. Clicking the down-arrow allows you to select "Save with encoding..." which allows you to choose Unicode (the default), ANSI (which is ASCII), or Chineese characters.

Huzza! Select the correct encoding for the type of file you want to output and voila! It's a done deal.

/john


That's good to know. Thanks for posting back.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search