Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"FOR XML" File Output from MSSQL7 is Not Readable by Excel 2007

Status
Not open for further replies.

minifelt

MIS
Jun 5, 2007
25
US
Business Requirement:
Automatically create an XML file from MSSQL7. The XML file must be readable by Excel 2007.

Here is what I have done:

1) I saved the following statement to myscript.sql:


use Mini_DW
go
select contractor_name,cid from CONTRACTOR
for XML AUTO



2)I ran this statement from the command promt:

osql -S cpiblade7 -U -h-1 -n -i c:\myscript.sql -o c:\myxml.xml


This successfully creates myxml.xml

3) Use Excel 2007 XML Data Import proces to Open myxml.xml

Excel returns this error:Invalid file reference. The path to the file is invalid or one or more of the referenced schema could not be found.
[/color red]

Here is the first few lines on myxml.xml

<CONTRACTOR contractor_name="3D Datacom " cid="1"/><CONTRACTOR contractor_na
me="568Systems, Inc" cid="2"/><CONTRACTOR contractor_name="A&amp;H Comm
unications, Inc." cid="3"/><CONTRACTOR contractor_name="ABC Electric
" cid="4"/><CONTRACTOR contractor_name="Able Communications" cid="5"/><
CONTRACTOR contractor_name="Access Communications Inc" cid="7"/><CONTRA
CTOR contractor_name="Access Data Network Solutions Inc.(Access DNSI)"
cid="8"/><CONTRACTOR contractor_name="ACI Communications" cid="9"/>


I also noticed that the last line of the xml file doesn't seem to have the correct end tag:

<CONTRACTOR contractor_name="Boe-Tel Company" c
id="34"/><CONTRACTOR contractor_name=" [/color red]

What am I doing wrong? I'm familiar with HTML but have limited experience on XML.

So sorry we're still stuck in the dark ages -- MSSQL7.

Thank you much for your help.
 
Hello, I made a mistake - We're using SQL2000 not MSSQL7. I was misled my the root director MSSQL7
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top