|
Posted by John Bell on 12/18/05 21:13
Answered on microsoft.public.sqlserver.server
John
"Matt" <mattfisch@charter.net> wrote in message
news:7cuaq1t87l5uge1qop3nceavdk47b94km0@4ax.com...
>
> Greetings,
> I am having some trouble with a trigger. This is my first attempt at
> creating a trigger so any help would be great. The function of the
> trigger is, on the insert of a row to check the value inserted into to
> column VEH_REPAIR_CODE. If that value is not 19, send an email to the
> value inserted in column VEH_CREW_CK_LANID. The email would include
> the values inserted from columns VEH_CREW_CK_LANID and
> VEHICLE_CHECK_ID ( the primary key of the table so the value is
> inserted from the system). If have the following syntax but it does
> not seem to work.
>
> Thank you for any help you can provide.
>
> CREATE TRIGGER car_check_repair_insert ON dbo. VEHICLE_CHECK FOR
> INSERT AS
> BEGIN
> DECLARE @CREW_1 VARCHAR(20)
> DECLARE @UNIT_1 VARCHAR(20)
> DECLARE @VEH_REPAIR_CODE INT
>
> DECLARE @MCC_ID VARCHAR(10)
> BEGIN
> SELECT @VEH_REPAIR_CODE = INSERTED.VEH_REPAIR_CODE, @CREW_1 =
> INSERTED.VEH_CREW_CK_LANID, @UNIT_1 = INSERTED.VEHICLE_NUM,@MCC_ID=
> VEHICLE_CHECK_ID
> From INSERTED
> IF @VEH_REPAIR_CODE <> 19
> BEGIN
> --Send the email here
> DECLARE @MAIL_TO VARCHAR(50)
> DECLARE @AUNIT VARCHAR(150)
> DECLARE @MCID VARCHAR(20)
>
> SELECT @MAIL_TO = @CREW_1 + '@exrch.site.com',@AUNIT ='unit
> number ' + @UNIT_1 + ' Reference number ' + @MCID '
> exec master.dbo.xp_sendmail @recipients = @MAIL_TO,
> @message = @AUNIT,
> @subject = 'car check'
>
>
> END
> END
> END
Navigation:
[Reply to this message]
|