dbTalk Databases Forums  

SSIS - Creating an XML File

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SSIS - Creating an XML File in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dave
 
Posts: n/a

Default SSIS - Creating an XML File - 01-05-2006 , 08:21 PM






I am trying to generate an XML file based on the result of a SQL Query.

In the absence of an XML Destination shape, I've done the following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file with the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.


Reply With Quote
  #2  
Old   
Patrik Schneider
 
Posts: n/a

Default RE: SSIS - Creating an XML File - 01-09-2006 , 04:51 PM






Dave,

You could place your query in the SQL command of the "OLEDB Source" in a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

Quote:
I am trying to generate an XML file based on the result of a SQL Query.

In the absence of an XML Destination shape, I've done the following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file with the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.


Reply With Quote
  #3  
Old   
Dave
 
Posts: n/a

Default RE: SSIS - Creating an XML File - 01-09-2006 , 11:22 PM



Hi Patrik,

thanks for that. I'm having problems using a SQL command/query that returns
XML with the OLEDB Source. It complains that data source does not have column
names.

Any ideas?

Cheers,
Dave.


"Patrik Schneider" wrote:

Quote:
Dave,

You could place your query in the SQL command of the "OLEDB Source" in a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

I am trying to generate an XML file based on the result of a SQL Query.

In the absence of an XML Destination shape, I've done the following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file with the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.


Reply With Quote
  #4  
Old   
Patrik Schneider [MSFT]
 
Posts: n/a

Default Re: SSIS - Creating an XML File - 01-10-2006 , 01:21 PM



Dave,

Below is an example of a command where I've named the output "myColumn":

select (select name, object_id
from sys.objects
for xml auto, type) as myColumn

~Patrik

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi Patrik,

thanks for that. I'm having problems using a SQL command/query that
returns
XML with the OLEDB Source. It complains that data source does not have
column
names.

Any ideas?

Cheers,
Dave.


"Patrik Schneider" wrote:

Dave,

You could place your query in the SQL command of the "OLEDB Source" in a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

I am trying to generate an XML file based on the result of a SQL Query.

In the absence of an XML Destination shape, I've done the following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file with
the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.




Reply With Quote
  #5  
Old   
Dave
 
Posts: n/a

Default Re: SSIS - Creating an XML File - 01-10-2006 , 03:30 PM



Thanks patrik,

I see what your trying to do, but I get a syntax error with the format
you've suggested.

I did this simple "Northwind" example below that copies the format you
suggested. Have I got this right?

select(
select EmployeeID, FirstName
from dbo.Employees
for xml auto, type) as myColumn

"Patrik Schneider [MSFT]" wrote:

Quote:
Dave,

Below is an example of a command where I've named the output "myColumn":

select (select name, object_id
from sys.objects
for xml auto, type) as myColumn

~Patrik

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote in message
news:EB19D34C-A224-4218-A200-AAC34F136955 (AT) microsoft (DOT) com...
Hi Patrik,

thanks for that. I'm having problems using a SQL command/query that
returns
XML with the OLEDB Source. It complains that data source does not have
column
names.

Any ideas?

Cheers,
Dave.


"Patrik Schneider" wrote:

Dave,

You could place your query in the SQL command of the "OLEDB Source" in a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

I am trying to generate an XML file based on the result of a SQL Query.

In the absence of an XML Destination shape, I've done the following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file with
the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.





Reply With Quote
  #6  
Old   
Patrik Schneider [MSFT]
 
Posts: n/a

Default Re: SSIS - Creating an XML File - 01-11-2006 , 04:17 PM



Dave,

SQL Server 2000 will return a syntax error on "xml" in the query. The "For
XML" clause is new to SQL Server 2005.

Could you post an example of the query that you were using to retrieve the
XML data in your Execute SQL Task?

Patrik
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote

Quote:
Thanks patrik,

I see what your trying to do, but I get a syntax error with the format
you've suggested.

I did this simple "Northwind" example below that copies the format you
suggested. Have I got this right?

select(
select EmployeeID, FirstName
from dbo.Employees
for xml auto, type) as myColumn

"Patrik Schneider [MSFT]" wrote:

Dave,

Below is an example of a command where I've named the output "myColumn":

select (select name, object_id
from sys.objects
for xml auto, type) as myColumn

~Patrik

--
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote in message
news:EB19D34C-A224-4218-A200-AAC34F136955 (AT) microsoft (DOT) com...
Hi Patrik,

thanks for that. I'm having problems using a SQL command/query that
returns
XML with the OLEDB Source. It complains that data source does not have
column
names.

Any ideas?

Cheers,
Dave.


"Patrik Schneider" wrote:

Dave,

You could place your query in the SQL command of the "OLEDB Source" in
a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

I am trying to generate an XML file based on the result of a SQL
Query.

In the absence of an XML Destination shape, I've done the
following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file
with
the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.







Reply With Quote
  #7  
Old   
Dave
 
Posts: n/a

Default Re: SSIS - Creating an XML File - 01-11-2006 , 09:18 PM



Ah, I see.

The "For xml" clause is actually valid in SQL 2000 - but the syntax of
returning the XML as a column (below) seems only to be valid in 2005.

Thanks.

select (select name, object_id
from sys.objects
for xml auto, type) as myColumn

"Patrik Schneider [MSFT]" wrote:

Quote:
Dave,

SQL Server 2000 will return a syntax error on "xml" in the query. The "For
XML" clause is new to SQL Server 2005.

Could you post an example of the query that you were using to retrieve the
XML data in your Execute SQL Task?

Patrik
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote in message
news:C65FD823-3402-43D1-8361-9691E04EBDA0 (AT) microsoft (DOT) com...
Thanks patrik,

I see what your trying to do, but I get a syntax error with the format
you've suggested.

I did this simple "Northwind" example below that copies the format you
suggested. Have I got this right?

select(
select EmployeeID, FirstName
from dbo.Employees
for xml auto, type) as myColumn

"Patrik Schneider [MSFT]" wrote:

Dave,

Below is an example of a command where I've named the output "myColumn":

select (select name, object_id
from sys.objects
for xml auto, type) as myColumn

~Patrik

--
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Dave" <Dave (AT) discussions (DOT) microsoft.com> wrote in message
news:EB19D34C-A224-4218-A200-AAC34F136955 (AT) microsoft (DOT) com...
Hi Patrik,

thanks for that. I'm having problems using a SQL command/query that
returns
XML with the OLEDB Source. It complains that data source does not have
column
names.

Any ideas?

Cheers,
Dave.


"Patrik Schneider" wrote:

Dave,

You could place your query in the SQL command of the "OLEDB Source" in
a
data flow and use the "Flat File Destination" to accomplish the same.

Hope this helps,
Patrik

"Dave" wrote:

I am trying to generate an XML file based on the result of a SQL
Query.

In the absence of an XML Destination shape, I've done the
following...

1. Exec SQL Statement returns XML & populates a string variable.

2. Use a script component to create a file and write to the file
with
the
variable.

Is anyone aware of patterns that involve less code?

Cheers,
Dave.








Reply With Quote
Reply




Thread Tools
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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.