Hi Steve, i like your idea....i will do that...please see new code...its working partially only if i put column ConfigSetID in @body...but if i add Name,Version and Timestamp in @body... i'm unable to update the table....not sure whats the issue...i'm not using cast or convert operator
USE [TriggerTest]
GO
/****** Object: Trigger [dbo].[Newrecordadded] Script Date: 04/12/2013 15:34:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create TRIGGER [dbo].[ConfigTrigger]
ON [dbo].[ConfigSet]
AFTER INSERT, DELETE, UPDATE
AS
DECLARE @ConfigSetID_Ins varchar(100)
DECLARE @ConfigSetID_Del varchar(100)
DECLARE @Body varchar(500)
Declare @Subject varchar(104)
Declare @Name varchar(64)
--Declare @Version smallint
--Declare @Timestamp binary(8)
BEGIN
Select @Subject = 'New record has been added in ConfigSet table in xxxxxxx';
SELECT @ConfigSetID_Ins = C.ConfigSetID, @Name = c.Name --@Version = c.Version,
--@Timestamp = c.[Timestamp]
from inserted i join ConfigSet C on I.ConfigSetID = C.ConfigSetID
--SELECT @ConfigSetID_Del = C.ConfigSetID
--from DELETED d join ConfigSet C on d.ConfigSetID = C.ConfigSetID
SET @body = 'New record '+'''' + @ConfigSetID_Ins + ',' + @Name + ',' --+ @Timestamp
+ ''''+' has been added to '+'CongifSet table in xxxxx'
EXEC msdb..sp_send_dbmail
@profile_name = 'xxxxxx',
@recipients = 'venkat@.com',
@subject = @subject,
@body = @body
END
GO
after creating this trigger....i tried modifying table to get email...but its not allowing me to update..i got this error..please suggest
Msg 245, Level 16, State 1, Procedure ConfigTrigger, Line 27
Conversion failed when converting the varchar value ' , ' to data type int.