Home > Archive > MS SQL XML > November 2006 > SQLXML encoding setting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQLXML encoding setting
Zheka212

2006-11-22, 7:16 pm

Hi Guys and Gals,

I use a simple vbscript inside of a DTS package to produce XML files.


Function Main()

Dim oCmd, sSQL, oDom
''' If MSXML 4.0 is not installed this will not work!
Set oDom = CreateObject("Msxml2.DOMDocument.4.0")

Set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection = " Provider=SQLOLEDB;Da
ta
Source=mySQLServer;I
nitial Catalog=myDB;Integra
ted Security=SSPI"

sSQL = "<COUNTRY_LOOKUP><sql:query
xmlns:sql='urn:schem
as-microsoft-com:xml-sql'>" & _
"SELECT " & _
"country_name = name_long " & _
", country_code = iso_country " & _
"INTO #MYTEMP " & _
"FROM countries c WITH (NOLOCK) " &_
"SELECT * FROM #MYTEMP COUNTRY_LOOKUP FOR XML
AUTO</sql:query></COUNTRY_LOOKUP>"

oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"


oCmd.Properties("Output Stream") = oDom
oCmd.Execute , , 1024

oDom.Save "c:\country_lookup.xml"
Main = DTSTaskExecResult_Su
ccess

End Function

Now, how do I go about adding the following line to this file?

<?xml version="1.0" encoding="iso-8859-1" ?>

Thanks in advance.
Eugene

Han

2006-11-24, 12:17 am

Hello

The returned XML stream from DB should be utf-8. If you just add the
declaration with iso-8859-1 without changing the encoding of the whole XML,
the XML may become corrupted. If you want to change the encoding of the
whole XML, you can use XSL with @encoding attribute of iso-8859-1.

"Zheka212" <egolyanov@gmail.com> wrote in message
news:1164230638.916330.128350@h54g2000cwb.googlegroups.com...
> Hi Guys and Gals,
>
> I use a simple vbscript inside of a DTS package to produce XML files.
>
>
> Function Main()
>
> Dim oCmd, sSQL, oDom
> ''' If MSXML 4.0 is not installed this will not work!
> Set oDom = CreateObject("Msxml2.DOMDocument.4.0")
>
> Set oCmd = CreateObject("ADODB.Command")
> oCmd.ActiveConnection = " Provider=SQLOLEDB;Da
ta
> Source=mySQLServer;I
nitial Catalog=myDB;Integra
ted Security=SSPI"
>
> sSQL = "<COUNTRY_LOOKUP><sql:query
> xmlns:sql='urn:schem
as-microsoft-com:xml-sql'>" & _
> "SELECT " & _
> "country_name = name_long " & _
> ", country_code = iso_country " & _
> "INTO #MYTEMP " & _
> "FROM countries c WITH (NOLOCK) " &_
> "SELECT * FROM #MYTEMP COUNTRY_LOOKUP FOR XML
> AUTO</sql:query></COUNTRY_LOOKUP>"
>
> oCmd.CommandText = sSQL
> oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
>
>
> oCmd.Properties("Output Stream") = oDom
> oCmd.Execute , , 1024
>
> oDom.Save "c:\country_lookup.xml"
> Main = DTSTaskExecResult_Su
ccess
>
> End Function
>
> Now, how do I go about adding the following line to this file?
>
> <?xml version="1.0" encoding="iso-8859-1" ?>
>
> Thanks in advance.
> Eugene
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com