Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Pulling SQL Data into an XML file

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2010-05-03 : 15:01:09
I need help pulling data from a Table into xml file. I need this data to be updated daily. So, I can always have the latest data from the SQL Table. Any idea of how to do this. Thank you for the help.

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-05-03 : 15:51:33
a simple example:


create table AB
(te_xt varchar(10)
,te_xt2 varchar(20)
)

insert into AB
select 'text9','text6' union all
select 'text2','text4' union all
select 'text3','text5'

select
te_xt
,te_xt2
,'' as rownumber
from AB

SELECT
te_xt, te_xt2
FROM AB
FOR XML PATH
go



prepare the select query on daily basis in such way to generate xml. Using SSIS package you can save this into XML file.
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2010-05-03 : 16:02:02
Ok. Maybe it will help if I give you the table structure. Table Responsibilities
Column 1 --Code,
Column 2 --Application,
Column 3 --Responsibility,
Column 4 --Description.

How to import this columns into xml file. Then how to update this xml file on the daily basic. I need to export this file inside a program that will read this file to populate a dropdownlist. Thank you for your help.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-03 : 16:42:25
quote:
I need to export this file inside a program that will read this file to populate a dropdownlist. Thank you for your help.


Maybe I'm missing something, but why not populate the dropdown directly by reading the table?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-05-03 : 16:53:26
Any chance you can post the layout of the XML document?


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2010-05-03 : 16:58:08
Good Point.....I am trying to avoid the postback action. If I read the table, I have to do a postback.
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2010-05-03 : 17:00:02
If I read directly from the Table, I have to do a postback. If I stored the information inside xml file everything is in the client side.
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2010-05-03 : 17:01:35
The xml file will look something like this.

-----------------------------------------------------------
<code>
<dbo.GSP_Responsibilities_and_Approvers_2 RESPONSIBILITY_NAME="DR SYS Help Desk Admin" RESPONSIBILITY_KEY="DR-HELP DESK" />
<dbo.GSP_Responsibilities_and_Approvers_2 RESPONSIBILITY_NAME="DR SYS Help Desk Reset Pwd" RESPONSIBILITY_KEY="DR_SYS_HELP_DESK_RESET_PWD" />
<dbo.GSP_Responsibilities_and_Approvers_2 RESPONSIBILITY_NAME="DR SYS System Administrator Inquiry" RESPONSIBILITY_KEY="DR_SYS_SYSTEM_ADMIN_INQUIRY" />
</code>
Go to Top of Page
   

- Advertisement -