July 30, 2004 at 6:21 am
Good Day All
I want to create a trigger that will send records INSERTED into a notepad. Can you please help with the syntax
CREATE TRIGGER Test ON [Table1]
FOR INSERT
NOT FOR REPLICATION
AS
/*Instead of Inserting into another table, I WANT TO INSERT DATA INTO A NOTE PAD */
July 30, 2004 at 7:06 am
I assume you are talking about writing some details to a text file. Try this ...this is from BOL.
This example writes the contents of the @var variable to a file named var_out.txt in the current server directory.
DECLARE @cmd sysname, @var sysnameSET @var = 'Hello world'SET @cmd = 'echo ' + @var + ' > var_out.txt'EXEC master..xp_cmdshell @cmd
I guess you might have to use xp_cmdshell. check out BOL for further details.
Cheers!
Arvind
August 1, 2004 at 9:56 pm
With a bit of work, you can also set up a linked server connection to a text file instead of resorting to xp_cmdshell. An example is given of how to set up such a connection in Books Online under the system stored procedure sp_addlinkedserver.
K. Brian Kelley
@kbriankelley
August 2, 2004 at 3:58 am
Thats cool Brian! Didnt know that cud be done.
Cheers!
Arvind
August 2, 2004 at 6:31 pm
Warning on that, though; potential performance problems, as you're making the completion of a transaction dependent on external processes completing.
cl
Signature is NULL
August 2, 2004 at 9:43 pm
Agreed. It is probably better here to load the data to a table from the trigger and then have an automated process pull the information asynchronous from the user.
K. Brian Kelley
@kbriankelley
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply