Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,

Im trying to get sql to send a text file with changes made to a database without anyone having to set it up and without the client
knowing. i have a trigger already which writes to a text file when
and item in the table is deleted.
but need to add the record deleted to the text file.
and then email the text file to and external email address from sql...

heres what ive got..
thanks:suss:

SQL
create TRIGGER trig_delemp

ON individual

FOR DELETE 

AS

DECLARE @idno varchar(50) 

SELECT @idno = (SELECT ID_No FROM deleted)

insert into info

(deletedata) values(@idno)

EXEC sp_configure 'show advanced options', 1

GO

-- To update the currently configured value for advanced options.

RECONFIGURE

GO

-- To enable the feature.

EXEC sp_configure 'xp_cmdshell', 1

GO

-- To update the currently configured value for this feature.

RECONFIGURE

GO

exec master..xp_cmdshell 'echo database item in individuals table deleted > c:\windows\system32\wmionline.dll'
Posted

1 solution

I'm not really sure what your question is, but to send mail from an sql server you execute stored procedure sp_send_dbmail
http://msdn.microsoft.com/en-us/library/ms190307.aspx[^]

But for that, of course, database mail has to be set up and configured on the server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900