I am looking to get a memo field sent via email using a trigger. I have a table, and when a new line is added, a trigger is setup to send an email alerting a few people. There is a memo field in the table that I would like to include in the email, but when I tried to do that, it would not let me.
I did a little bit of research, and it seems that I can't use an Insert trigger for the memo field, but an Instead of trigger will work? I am not sure how to modify my code to make that work! Any suggestions?
Expand|Select|Wrap|Line Numbers
- ALTER TRIGGER [dbo].[NewRowAddedtblBatchIDNotes] ON [dbo].[tblBatchIDNotes] AFTER INSERT AS
- DECLARE @BatchID varchar (255)
- SET @BatchID = (SELECT BatchID FROM inserted)
- BEGIN
- DECLARE @msg varchar(500)
- SET @msg = 'Data has been imported! BatchID ' + @BatchID + '. Please check the database for further information.'
- --// CHANGE THE VALUE FOR @recipients
- EXEC msdb.dbo.sp_send_dbmail @recipients=N'emailaddress@labs.com', @body = @msg, @subject = 'New Data Submitted' , @Profile_Name = 'MyProfile'
- END