473,385 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using trigger to export xml file

Hi all,

i am having trouble trying to export this in xml. Basically inside an
update trigger i need to export in xml or file the qty that has been
changed. This then gets updated to another system. Is this a good idea
? should i be using another table in between in case something happens
on the other end?

However, I tried something like this and it didn't recognize the
selected table inside the bcp:

CREATE TRIGGER [TRIGGER NAME] ON [fastpic].[FP_INVTRANS]
FOR INSERT, UPDATE
AS

DECLARE @selected varchar (100)

IF NOT UPDATE(system_qty)

BEGIN

RETURN

END

DECLARE @cmd varchar(200)
set @cmd = 'bcp "select system_qty, part_name from selected " queryout
c:\parts.xml -S. -Usa -P -c -r -t'
exec master ..xp_cmdshell @cmd '

IF someone could help or suggest something else i would appreciate it,
than you

May 4 '06 #1
1 8326
(ly****@gmail.com) writes:
i am having trouble trying to export this in xml. Basically inside an
update trigger i need to export in xml or file the qty that has been
changed. This then gets updated to another system. Is this a good idea
? should i be using another table in between in case something happens
on the other end?
Definitely. Triggers runs in the context of a transaction, and
forking out to xp_cmdshell in a trigger is definitely not good
practice.

I don't know what sort of users that update this table, but they
need hefty privileges to xp_cmdshell. That alone is enough to
repclude this solution. Besides, I don't think you can get BCP to
export in XML.

Write a notification of the changed row to a table, and the write
a job that reads this table periodically. This should not be a
T-SQL job, but a command-line job or an Active-X task. The command
job would be a console program in VB, C# or C++ that is able to read
the XML.
However, I tried something like this and it didn't recognize the
selected table inside the bcp:


Since it's a new login, you need to specify the database name in
the query. But, as I said, you should not do this anyway.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Leslie Houk | last post by:
I'm just learning PHP, and I'm having a problem using fpassthru(). I want to download a file using the following code segment I found, which I put into my testing file called portal.php: ...
3
by: Terri | last post by:
I'm using xp_cmdshell to output a text file from a trigger like this CREATE TRIGGER ON tblApplications FOR INSERT AS DECLARE @FirstName varchar(75) DECLARE @LastName varchar(75) Declare...
9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
2
by: kk | last post by:
Hello, Help! Does anyone have an example of a trigger that will export a newly inserted row into a flat file? Basically anytime a row is inserted into a specific table a flatfile (fixed width)...
6
by: maricel | last post by:
Is there anybody out there who have any idea why EXPORT is relatively slower when putting the output file on a network drive - map drive from onother PC compared to putting it on my local PC drive...
10
by: Neil | last post by:
Hi guyz, just trying out this google feature so if i post if in the wrong area i appologize. now to my question. BTW i'm new to access programming, i've done a little vb6.0 and vb.net but access...
3
by: Rudy | last post by:
Hello all! This is what I want to do, looking the for the best way to do this. I have a text file that gets created and placed in a folder. I would like to have a watch for that file when it pops...
5
by: RadhakrishnanR | last post by:
Hi, By using VB6.0, I want to export database table data into (i.e based on the selected file type(xls or txt)) excel file or text file with a tab delimited text file. My User interface has: ...
14
by: aaragon | last post by:
Hi everyone, I've been writing some code and so far I have all the code written in the .h files in order to avoid the linker errors. I'm using templates. I wanted to move the implementations to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.