July 25, 2013 at 11:07 am
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
July 25, 2013 at 1:45 pm
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.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
July 25, 2013 at 2:10 pm
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
July 25, 2013 at 2:13 pm
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.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
July 25, 2013 at 2:17 pm
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
July 25, 2013 at 2:29 pm
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 🙂
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
July 25, 2013 at 3:49 pm
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
July 26, 2013 at 12:53 am
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.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply