![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
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. |
#5
| |||
| |||
|
|
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. |
#6
| |||
| |||
|
|
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. |
#7
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |