Unicode Job Output | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Unicode Job Output

When running a job through SQL Agent I am outputting the results to a file by setting an output file for the individual job step. By default SQL Server is creating this file in Unicode. This is causing me problems with other systems that need to read this file but do not support Unicode. Is there a way to override the SQL Server default of using Unicode and use ANSI instead?
What is the collation setting on this SQL Server? _________
Satya SKJ
Moderator
SQL-Server-Performance.Com

Can you post the code for steps carried out in the job here? Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

Latin1_General_Cl_AS Thanks
I do not have access to the job but having spoken to the guy that developed it the job is based around a single step. This step calls a stored procedure that performs various processing and executes a SQL statement before terminating. It is the results of this SQL statement that are being logged by SQL Server in Unicode text. This is very similar to executing a stored procedure in query analyser and viewing the results in the output pane but the output pane does not exist so the results go to a text file.
I have checked at my end and tried exporting the job step result to a file and it creates the ANSI standard format, whereas the database has the same collation specified by you. BTW, what is the error when you open the text file on other systems? _________
Satya SKJ
Moderator
SQL-Server-Performance.Com

does your table or query produce any columns with nvarchar, nchar or ntext columns?
There are no nvarchar or nchar columns in the job
The job step is documented by SQL Enterprise manager as follows: EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep
@job_id = @JobID,
@step_id = 1,
@step_name = N’Run SP’,
@command = N’EXEC ie_error_report 24, ”LUCE_I”’,
@database_name = N’IE’,
@server = N”,
@database_user_name = N’ie’,
@subsystem = N’TSQL’,
@cmdexec_success_code = 0,
@flags = 2,
@retry_attempts = 0,
@retry_interval = 1,
@output_file_name = N’E:Error ReportsLatest Report.txt’,
@on_success_step_id = 0,
@on_success_action = 1,
@on_fail_step_id = 0,
@on_fail_action = 2
Try removing ‘N’ in @output_file_name = N’E:Error ReportsLatest Report.txt’,
Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

Was there ever a resolution to this? We too are running a job through SQL Agent and have the same issue. By default SQL Server is creating this file in Unicode. This is causing us problems when we call sp_send_cdosysmail to email the output file as an attachment to recipients. If attachment is converted to ANSI file and is emailed it then is legible. Is there a parameter to override SQL Server agent or in SQL server itself to change the default file output setting from using Unicode to use ANSI instead? ddillon
]]>