May 4, 2008 at 11:28 am
Hi,
I am using OLE automation stored procedures, in particular the sp_OAMethod, to write to a text file using SQL Server 2005. Here is the line of code:
execute @hr = sp_OAMethod @objTextStream, 'Write', Null, @String
@String is a varchar not a nvarchar.
However, the output file is in UTF-16, not ASCII as was desired.
Anyone know how to ensure that my output file is in ASCII? Also, if anyone knows of an environment to display the file in to discern whether it is ASCII or UTF-16, that is welcome too.
May 4, 2008 at 12:02 pm
I think I have discovered an answer:
"...OLE DB is based on COM, and thus all the strings are Unicode BSTRs (UTF-16 on Windows 2000, and UCS-2 on all other operating systems). For SQL Server, the provider is the Microsoft OLE DB Provider for SQL Server (SQLOLEDB). Data is converted to Unicode as needed, using the collation of the actual data."
http://technet.microsoft.com/en-us/library/aa902644(SQL.80).aspx
So, does anyone know a way to get around this or a something I could call in my stored procedure after creating my .txt file to convert it from UTF-16 to ASCII?
Thanks,
Jessica
May 6, 2008 at 7:18 am
I have the same problem. I tried
EXECUTE sp_OASetProperty @objTextStream, 'Charset', 'utf-8'
EXECUTE sp_OASetProperty @objTextStream, 'Charset', 'windows-1252'
but these did not change the output character set, I don't know if this is on the right path but it seemed to make sense.
June 24, 2008 at 7:29 pm
Did anyone ever find an answer on this? If not, does anyone know the answer for this?
--Jeff Moden
Change is inevitable... Change for the better is not.
June 26, 2008 at 5:59 am
Hi Jeff,
I couldn't find a way to get this to work, so I used the method described by Will in this post:
http://www.sqlservercentral.com/Forums/Topic450843-23-1.aspx
Jessica
September 14, 2015 at 6:33 am
use at First Create
Exec sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
ok
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply