Quantcast
Channel: SQL Query Stalls While Importing a ClickBank XML feed into SQL Database
Viewing all articles
Browse latest Browse all 48

SQL Query Stalls While Importing a ClickBank XML feed into SQL Database

$
0
0

Hey Folks,

I need a SQL Query to Import an XML Datafeed for Clickbank -- which is located at: http://www.clickbank.com/feeds/marketplace_feed_v2.xml.zip -- into a SQL Server Database running on Microsoft SQL Server Management Studio Express9.00.4035.00.

I created a query to create a table and import the data from the XML file (Unzipped and on the server) and it seems to work if I limit the number of records in the source file.

Unfortunately, if I try to import the entire file, it runs forever -- actually I tried to run it solid for three days and it never stopped, so I finally killed it.

No errors generated, but it just seems to hang there. I realize it's quite a few records, but it shouldn't take that long.

Here is the query I wrote to create the file and import the XML data.   Any help you can give is appreciated.

USE [Portalcube]
GO
/****** Object:  Table [dbo].[cbimport]    Script Date: 01/29/2012 19:34:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cbimport]') AND type in (N'U'))
DROP TABLE [dbo].[cbimport]


USE [Portalcube]
GO
/****** Object:  Table [dbo].[cbimport]    Script Date: 01/29/2012 19:33:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[cbimport](
	[cbprodID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [char](50) NULL,
	[Site] [char](50) NULL,
	[Id] [char](50) NULL,
	[PopularityRank] [char](50) NULL,
	[Title] [varchar](100) NULL,
	[Description] [varchar](5000) NULL,
	[HasRecurringProducts] [char](50) NULL,
	[Gravity] [char](25) NULL,
	[EarnedPerSale] [char](25) NULL,
	[PercentPerSale] [char](25) NULL,
	[TotalEarningsPerSale] [char](25) NULL,
	[TotalRebillAmt] [char](25) NULL,
	[Referred] [char](25) NULL,
	[Commission] [char](25) NULL,
	[ActivateDate] [char](25) NULL,
	[remarks] [text] NULL,
	[void] [char](1) NULL CONSTRAINT [DF_cbimport_void]  DEFAULT ((1)),
 CONSTRAINT [PK_cbimport] PRIMARY KEY CLUSTERED 
(
	[cbprodID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO



INSERT INTO CBIMPORT (CategoryName, Title, Site, PopularityRank, Description, HasRecurringProducts, Gravity, EarnedPerSale, PercentPerSale, TotalEarningsPerSale, TotalRebillAmt, Referred, Commission, ActivateDate) 
SELECT 
	a.b.query('..').value('Category[1]/Name[1]', 'VARCHAR(100)'), 
	a.b.query('Title').value('.', 'VARCHAR(100)'),
	a.b.query('Id').value('.', 'VARCHAR(100)'),
	a.b.query('PopularityRank').value('.', 'VARCHAR(20)'),
	a.b.query('Description').value('.', 'VARCHAR(max)'),
	a.b.query('HasRecurringProducts').value('.', 'VARCHAR(5)'),
	a.b.query('Gravity').value('.', 'VARCHAR(10)'),
	a.b.query('AverageEarningsPerSale').value('.', 'VARCHAR(10)'),
	a.b.query('PercentPerSale').value('.', 'VARCHAR(10)'),
	a.b.query('AverageEarningsPerSale').value('.', 'VARCHAR(10)'),
	a.b.query('TotalRebillAmt').value('.', 'VARCHAR(10)'),
	a.b.query('Referred').value('.', 'VARCHAR(20)'),
	a.b.query('Commission').value('.', 'VARCHAR(10)'),
	a.b.query('ActivateDate').value('.', 'VARCHAR(10)')
FROM ( 
SELECT Convert(xml, x, 2)
FROM OPENROWSET(
     BULK 'c:\websites\affiliateshowcase\upload\marketplace_feed_v2.xml',
     SINGLE_BLOB) AS T(x)
     ) AS T(x)
CROSS APPLY x.nodes('Catalog/Category/Site') AS a(b);
select * from cbimport

I'm open to ideas or any other ways to get that XML data into my cbimport table mapped like the above query.  I need a set query so that I can execute it daily.

MANY thanks!

All the best,

Ken


Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>