Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

trigger help
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_ins
ert 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

Report this thread to moderator Post Follow-up to this message
Old Post
Matt
12-18-05 02:23 PM


Re: trigger help
Answered on microsoft.public.sqlserver.server

John

"Matt" <mattfisch@charter.net> wrote in message
 news:7cuaq1t87l5uge1
 qop3nceavdk47b94km0@
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_ins
ert 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



Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
12-18-05 06:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 01:02 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006