RE: sql trigger that exports data

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: JoeDz (JoeDz_at_discussions.microsoft.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 13:29:05 -0700

Thanks for the examples Nigel;
I am trying the bcp example in a trigger, it almost works:

CREATE TRIGGER sensorData_insert ON sensorData
AFTER INSERT
AS
BEGIN
    exec master..xp_cmdshell 'bcp database..table out c:\triggerOut.bcp -S
server -U user-P password-c'
END;

One problem: when I insert a record, the table appears to be locked; the
triggerOut.bcp file is created, but empty. After a while I stop the server.
Then the triggerOut.bcp file is populated. Any idea what I am missing, seems
like the trigger is waiting for something to complete. Also, during this
'locked' period, I can not query the table.
Thanks for your help.

"JoeDz" wrote:

> I would like to create an insert trigger which will export the newly inserted
> record to a file in C:\Temp.
> Is there a way I can export data from within a trigger?
> Thanks.



Relevant Pages

  • Re: how to assign the contents of a field to a variable
    ... what happens if the MSMQ server is ... teh requirements of the trigger are to export an XML document to MSMQ ... DECLARE @int_msmqqueue INT ... IF @int_result 0 GOTO ErrorHandler ...
    (microsoft.public.sqlserver.programming)
  • Error beim mit trigger welcher auf einen anderen Server schreibt
    ... eine andere Tabelle auf der selben Datenbank schreibt. ... Auf dieser Tabelle ist ebenfalls ein Trigger, ... einen anderen Server in eine Tabelle schreibt. ... @OwnerLogin varchar, ...
    (microsoft.public.de.sqlserver)
  • Re: Alternative to Transactional Replication
    ... Basically the insert is wrapped in a transaction when you fire a trigger. ... Looking for a SQL Server replication book? ... with various WAN links. ...
    (microsoft.public.sqlserver.replication)
  • Help:Error 7405 - Problem accessing linked server in trigger
    ... I have written an insert trigger In SQL server 2K that is supposed to ... of the select query. ... Are these two SET statements the only suspect that caused my access ...
    (microsoft.public.sqlserver.programming)
  • Re: Alternative to Transactional Replication
    ... Basically the insert is wrapped in a transaction when you fire a trigger. ... Looking for a SQL Server replication book?http://www.nwsu.com/0974973602.html ... reporting purposes) across WAN links, ...
    (microsoft.public.sqlserver.replication)