Question : SQL TRIGGERS

I have created a trigger which automatically sends an email when coloum analysis_c is updated. The only problem is an email is sent everytime someone edits this coloum but I only want to send an email when the coloum is populated with the word 'DELETED'

Here is my current trigger;

CREATE TRIGGER Deleted_Products ON [scheme].[stockm]
FOR Update
AS
Declare @product VARCHAR(10)
Declare @description varchar(1000)
Declare @pickface varchar (10)
Declare @body varchar(2000)
Declare @Status varchar(100)


if not update (analysis_c)


begin

return

end



Select @product = product,
@description = description,
@pickface = packaging,
@Status = analysis_c
from inserted




set @body = ('Product' + ' ' + @product + @description + ' ' + 'has been moved to' + ' ' + @Status + 'Pickface' + ' ' + @pickface)

 EXEC master..xp_sendmail

            @recipients = '[email protected]',

            @subject = 'Product Information Updated',

              @message = @body

Can anyone point me in the right direction?

Answer : SQL TRIGGERS

sure:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
CREATE TRIGGER Deleted_Products ON [scheme].[stockm]
FOR Update
AS
Declare @product VARCHAR(10)
Declare @description varchar(1000)
Declare @pickface varchar (10)
Declare @body varchar(2000)
Declare @Status varchar(100)


if not update (analysis_c)
begin
  return
end

if not exists( select null from inserted where analysis_c = 'DELETED')
begin
  return
end



Select @product = product,
@description = description,
@pickface = packaging,
@Status = analysis_c
from inserted




set @body = ('Product' + ' ' + @product + @description + ' ' + 'has been moved to' + ' ' + @Status + 'Pickface' + ' ' + @pickface)

 EXEC master..xp_sendmail

            @recipients = '[email protected]',

            @subject = 'Product Information Updated',

              @message = @body
Random Solutions  
 
programming4us programming4us