If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Using FOR XML Explicit within a DTS package

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-07-04, 11:37
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
Question Using FOR XML Explicit within a DTS package

I created a SELECT statement that uses the FOR XML EXPLICIT clause so that SQL Server data can be exported to another system. Format thios system accepts is XML. What should I define within a DTS package so that this Select statement is executed and an XML file is created?
Reply With Quote
  #2 (permalink)  
Old 09-07-04, 12:02
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #3 (permalink)  
Old 09-07-04, 12:35
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
Hi, Brett

Does that BLOG hold the key to the answer I'm looking for?

RQ
Reply With Quote
  #4 (permalink)  
Old 09-07-04, 12:45
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
No....it's a rant about the use of XML...what's the destination for the data?

Why does it have to be in XML?

Is the destination another sql box?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #5 (permalink)  
Old 09-07-04, 12:58
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
Oh (on the rant part)...I might use that to vent later...

No, the destination is not another SQL box.

As I mentioned earler, our information system uses SQL Server 2000. We are trying to integrate our data with another online application. The preferred data format (rather the required format) is XML. I used the SELECT...FOR XML EXPLICIT to follow their IMS specs. I got this down pat but the part where I'm trying to send the resultset to an XML file format is where I'm stuck.
Reply With Quote
  #6 (permalink)  
Old 09-07-04, 13:01
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
I understand that it's part of the req...but what is the destination data engine?

And show us what you've got so far....
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #7 (permalink)  
Old 09-07-04, 13:47
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
Excuse my ignorance, what is the destination data engine? As an fyi, the company that maintains/administers the inline app metioned sometime ago that they use a proprietary database system maintained via Perl.

With regards to showing what I have so far, are you tallking about the Select SQL statement or the DTS package? If it's the latter, it's just a data connection icon, a transform data task and text file destination.
Reply With Quote
  #8 (permalink)  
Old 09-07-04, 14:49
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
Hi, Brett

I just found out that company uses Berkeley flat databases for its online application.

RQ
Reply With Quote
  #9 (permalink)  
Old 09-07-04, 14:58
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
No kidding...

http://www.stanford.edu/class/cs276a...o/dbisnot.html

Save your query as a view then dts it out...

or better yet, use bcp....

Where's the sql statement....
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #10 (permalink)  
Old 09-07-04, 15:08
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
SQL statement is below. I don't think the bcp will work on it (the Select statement), will it? How do you execute a view from a DT Spackage?


declare @NumberOfDays int
select @NumberOfDays = 21

select 1 as tag,
null as parent,
'' as [Enterprise!1],
null as [Properties!2!DataSource!element],
null as [Properties!2!DateTime!element],
null as [Group!3!!hide],
-- null as [Group!3!recstatus],
null as [Sourcedid!4!Source!element],
null as [Sourcedid!4!ID!element],
null as [Description!5!Short!element],
null as [Extension!6!Template!element]
from adterm a (nolock)
where a.code = '0001'
union
select 2 as tag,
1 as parent,
'',
'WebCT' as DataSource,
getdate() as DateTime,
null,
-- null,
null,
null,
null,
null
from adterm a (nolock)
where a.code = '0001'
union
select 3 as tag,
1 as parent,
'',
'WebCT' as DataSource,
getdate() as DateTime,
rtrim( a.code ) + cast( a.adclassschedid as char( 14 ) ) as [Group!3!!hide],
-- 1 as recstatus,
null,
null,
null,
null
from adclasssched a (nolock)
inner join adclassschedterm b (nolock)
on a.adclassschedid = b.adclassschedid
inner join adterm c (nolock)
on b.adtermid = c.adtermid
and ( getdate() + @NumberOfDays ) between c.startdate and c.enddate
and len( rtrim( c.code ) ) = 4
and c.active = 1
inner join adcourse d (nolock)
on a.adcourseid = d.adcourseid
and d.code not like 'elec%'
union
select 4 as tag,
3 as parent,
'',
'WebCT' as DataSource,
getdate() as DateTime,
rtrim( a.code ) + cast( a.adclassschedid as char( 14 ) ) as [Group!3!!hide],
-- 1 as Recstatus,
'The College of Westchester: Campus2000' as Source,
rtrim( a.code ) + '-' + rtrim( a.section ) + '-' + rtrim( c.code ) as ID,
null,
null
from adclasssched a (nolock)
inner join adclassschedterm b (nolock)
on a.adclassschedid = b.adclassschedid
inner join adterm c (nolock)
on b.adtermid = c.adtermid
and ( getdate() + @NumberOfDays ) between c.startdate and c.enddate
and len( rtrim( c.code ) ) = 4
and c.active = 1
inner join adcourse d (nolock)
on a.adcourseid = d.adcourseid
and d.code not like 'elec%'
union
select 5 as tag,
3 as parent,
'',
'WebCT' as DataSource,
getdate() as DateTime,
rtrim( a.code ) + cast( a.adclassschedid as char( 14 ) ) as [Group!3!!hide],
-- 1 as Recstatus,
'The College of Westchester: Campus2000' as Source,
rtrim( a.code ) + '-' + rtrim( a.section ) + '-' + rtrim( c.code ) as ID,
rtrim( a.descrip ) + '-' + rtrim( a.section ),
null
from adclasssched a (nolock)
inner join adclassschedterm b (nolock)
on a.adclassschedid = b.adclassschedid
inner join adterm c (nolock)
on b.adtermid = c.adtermid
and ( getdate() + @NumberOfDays ) between c.startdate and c.enddate
and len( rtrim( c.code ) ) = 4
and c.active = 1
inner join adcourse d (nolock)
on a.adcourseid = d.adcourseid
and d.code not like 'elec%'
union
select 6 as tag,
3 as parent,
'',
'WebCT' as DataSource,
getdate() as DateTime,
rtrim( a.code ) + cast( a.adclassschedid as char( 14 ) ) as [Group!3!!hide],
-- 1 as Recstatus,
'The College of Westchester: Campus2000' as Source,
rtrim( a.code ) + '-' + rtrim( a.section ) + '-' + rtrim( c.code ) as ID,
rtrim( a.descrip ) + '-' + rtrim( a.section ),
rtrim( a.code ) + '_Template'
from adclasssched a (nolock)
inner join adclassschedterm b (nolock)
on a.adclassschedid = b.adclassschedid
inner join adterm c (nolock)
on b.adtermid = c.adtermid
and ( getdate() + @NumberOfDays ) between c.startdate and c.enddate
and len( rtrim( c.code ) ) = 4
and c.active = 1
inner join adcourse d (nolock)
on a.adcourseid = d.adcourseid
and d.code not like 'elec%'
order by [Group!3!!hide],
[Sourcedid!4!ID!element],
[Description!5!Short!element],
[Extension!6!Template!element]
for xml explicit
Reply With Quote
  #11 (permalink)  
Old 09-10-04, 12:34
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
I give up....

Code:
USE Northwind
GO

CREATE VIEW myTable99
AS
SELECT 1                    as Tag, 
         NULL                 as Parent,
         Customers.CustomerID as [Customer!1!CustomerID],
         NULL                 as [Order!2!OrderID]
FROM Customers
UNION ALL
SELECT 2, 
         1,
         Customers.CustomerID,
         Orders.OrderID
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
ORDER BY [Customer!1!CustomerID], [Order!2!OrderID]
FOR XML EXPLICIT
GO

CREATE TABLE myTable99(Col1 varchar(8000))
GO

INSERT INTO myTable99(Col1)
SELECT * FROM (
SELECT 1                    as Tag, 
         NULL                 as Parent,
         Customers.CustomerID as [Customer!1!CustomerID],
         NULL                 as [Order!2!OrderID]
FROM Customers
UNION ALL
SELECT 2, 
         1,
         Customers.CustomerID,
         Orders.OrderID
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
ORDER BY [Customer!1!CustomerID], [Order!2!OrderID]
FOR XML EXPLICIT) AS XXX
GO

CREATE PROC mySproc99
AS
SELECT 1                    as Tag, 
         NULL                 as Parent,
         Customers.CustomerID as [Customer!1!CustomerID],
         NULL                 as [Order!2!OrderID]
FROM Customers
UNION ALL
SELECT 2, 
         1,
         Customers.CustomerID,
         Orders.OrderID
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
ORDER BY [Customer!1!CustomerID], [Order!2!OrderID]
FOR XML EXPLICIT
GO

EXEC mySproc99

INSERT INTO myTable99 EXEC mySproc99
GO

DROP TABLE myTable99
DROP PROC mySproc99
GO
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #12 (permalink)  
Old 09-10-04, 14:26
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
If you didn't see this link in the blog (gratefully donated by Jay)

Check it out

http://www.perfectxml.com/Articles/X...rtSQLXML.asp#4
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #13 (permalink)  
Old 09-10-04, 15:47
rq7 rq7 is offline
Registered User
 
Join Date: Sep 2004
Posts: 7
My sentiments -- just about -- on giving up.

Thanks for your suggestion, I'll give it a try.

The article you mentioned is informative but it said it works best on a small result set. I anticipate my result sets to vary -- with a lot leaning on pretty big result set sizes.

Many thanks for your help...
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On