p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2005 > SQL Server 2005
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 26th, 2009, 04:41 PM
Friend of Wrox
Points: 1,406, Level: 15
Points: 1,406, Level: 15 Points: 1,406, Level: 15 Points: 1,406, Level: 15
Activity: 12%
Activity: 12% Activity: 12% Activity: 12%
 
Join Date: Jul 2005
Location: , , .
Posts: 304
Thanks: 0
Thanked 0 Times in 0 Posts
Question HOW TO: Import XML Feed from Another Domain

I have a stored procedure (SP) that imports 2 internal XML feeds into a SQL Server 2005 table using Bulk Load/OPENROWSET without a problem. But I'd also like to import one more external XML feed that's not located on my domain into that same SP. When I enter the URL to that XML feed, I get this error message when I run the job:

Msg 4861, Level 16, State 1, Line 2
Cannot bulk load because the file "http://codeamber.org/a1xl04act/amberalert.xml" could not be opened. Operating system error code 123(The filename, directory name, or volume label syntax is incorrect.).

(1 row(s) affected)

From research, I'm *thinking* this is an issue regarding accessing data from another site/domain, but I can't say for sure. I'm able to do this in ASP.NET/VB.NET code without a problem, so I'm not sure why it wouldn't work within SQL Server 2005 somehow. I'm including the entire SP code below. If anyone can let me know what I'm doing wrong, it would be greatly appreciated. Thanks.

spXMLImport:
Code:
USE [DATABASENAME]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[spXMLImport]

AS
BEGIN

SET NOCOUNT ON;

DROP TABLE tblXMLFeeds

CREATE TABLE tblXMLFeeds
(
    record_id VARCHAR(50),
    xmlTitle VARCHAR(100),
        xmlFileName VARCHAR(300),
        xml_data xml,
    datestamp VARCHAR(23)
)

DECLARE @record_id_aa VARCHAR(50)
DECLARE @record_id_bb VARCHAR(50)
DECLARE @record_id_cc VARCHAR(50)
DECLARE @xmlTitle_aa VARCHAR(100)
DECLARE @xmlTitle_bb VARCHAR(100)
DECLARE @xmlTitle_cc VARCHAR(100)
DECLARE @xmlFileName_aa VARCHAR(300)
DECLARE @xmlFileName_bb VARCHAR(300)
DECLARE @xmlFileName_cc VARCHAR(300)
DECLARE @datestamp VARCHAR(23)

SELECT  @record_id_aa = 'aaID'
SELECT  @record_id_bb = 'bbID'
SELECT  @record_id_cc = 'ccID'

SELECT  @xmlTitle_aa = 'Internal Feed 1'
SELECT  @xmlTitle_bb = 'Internal Feed 2'
SELECT  @xmlTitle_cc = 'External Feed'

SELECT  @xmlFileName_aa = '\\SERVERNAME\DIRECTORY\docs\xml\internalfeed1.xml'
SELECT  @xmlFileName_bb = '\\SERVERNAME\DIRECTORY\docs\xml\internalfeed2.xml'
SELECT  @xmlFileName_cc = 'http://codeamber.org/a1xl04act/amberalert.xml' --<<<----EXTERNAL FEED
--******************I'VE ALSO TRIED THE FOLLOWING:******************
--SELECT  @xmlFileName_cc = '//codeamber.org/a1xl04act/amberalert.xml'
--SELECT  @xmlFileName_cc = '\\codeamber.org\a1xl04act\amberalert.xml'

--SET datestamp as ISO-8601 datetime format
SELECT @datestamp = CONVERT(VARCHAR(23), GETDATE(), 126)

EXEC('
INSERT INTO tblXMLFeeds(record_id, xmlTitle, xmlFileName, xml_data, datestamp)

SELECT ''' + @record_id_aa + ''', ''' + @xmlTitle_aa + ''', ''' + @xmlFileName_aa + ''', xmlData, ''' + @datestamp + '''
 
FROM
(
    SELECT  * 
    FROM    OPENROWSET (BULK N''' + @xmlFileName_aa + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)


INSERT INTO tblXMLFeeds(record_id, xmlTitle, xmlFileName, xml_data, datestamp)

SELECT ''' + @record_id_bb + ''', ''' + @xmlTitle_bb + ''', ''' + @xmlFileName_bb + ''', xmlData, ''' + @datestamp + '''
FROM
(
    SELECT  * 
    FROM    OPENROWSET (BULK N''' + @xmlFileName_bb + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)


INSERT INTO tblXMLFeeds(record_id, xmlTitle, xmlFileName, xml_data, datestamp)

SELECT ''' + @record_id_cc + ''', ''' + @xmlTitle_cc + ''', ''' + @xmlFileName_cc + ''', xmlData, ''' + @datestamp + '''
FROM
(
    SELECT  * 
    FROM    OPENROWSET (BULK N''' + @xmlFileName_cc + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)
')
END
__________________
KWilliams
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 7th, 2009, 11:36 AM
Friend of Wrox
Points: 1,406, Level: 15
Points: 1,406, Level: 15 Points: 1,406, Level: 15 Points: 1,406, Level: 15
Activity: 12%
Activity: 12% Activity: 12% Activity: 12%
 
Join Date: Jul 2005
Location: , , .
Posts: 304
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I received this response from someone else:
Quote:
Should use SSIS package to do this...1st step, import the file to your domain. Then do a bulk insert.
...but I can't figure out how to import an external XML file. If anyone can point me in the right direction, that would be great. Thanks for any help.
__________________
KWilliams
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a RSS feed in XML javaguy1007 RSS and Atom 0 March 31st, 2009 03:03 PM
ASP.NET XML Feed Error kwilliams ASP.NET 2.0 Professional 0 February 19th, 2008 05:41 PM
Problems parsing XML Feed in Javascript kwilliams Classic ASP Professional 0 December 18th, 2007 06:33 PM
xml feed with javascript jon8884 Javascript 5 June 22nd, 2005 02:15 PM
XML news feed sankar XML 1 December 17th, 2003 05:28 AM



All times are GMT -4. The time now is 11:45 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc