SeaninSeattle
IS-IT--Management
Ok - I really need some help. I'm trying to build a trigger on a table that with every insertion will look at the record inserted, and then, if it meets two condtions (SOPTYPE 2 and today's date in DOCDATE), will kick out an email via SQL Mail. This is what I have:
===============================
USE BSW2
/* delete any existing version of this trigger before attempting to create */
if exists
(select * from dbo.sysobjects
where id = object_id(N'[dbo].[EmailTR_SOP10100InsTrg]')
and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[EmailTR_SOP10100InsTrg]
GO
CREATE TRIGGER EmailTR_SOP10100InsTrg
ON [SOP10100]
FOR INSERT
AS
EXEC master..xp_sendmail 'SeanE', 'Table has been hit by SOPTYPE2!'
IF SOPTYPE = 2 and
SOP10100.SOPNUMBE in
(Select SOPNUMBE from SOP10100
where (Select convert(char(10),DOCDATE,1))
= (Select convert(char(10),getdate (),1)))
GO
================================
I keep getting a failure message on this telling me that there is a syntax error on the last line by ')'.
Any ideas??
Thanks in advance!
//sse
Sean Engle
Admin/DirIS
ssengle@bswusa.com
===============================
USE BSW2
/* delete any existing version of this trigger before attempting to create */
if exists
(select * from dbo.sysobjects
where id = object_id(N'[dbo].[EmailTR_SOP10100InsTrg]')
and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[EmailTR_SOP10100InsTrg]
GO
CREATE TRIGGER EmailTR_SOP10100InsTrg
ON [SOP10100]
FOR INSERT
AS
EXEC master..xp_sendmail 'SeanE', 'Table has been hit by SOPTYPE2!'
IF SOPTYPE = 2 and
SOP10100.SOPNUMBE in
(Select SOPNUMBE from SOP10100
where (Select convert(char(10),DOCDATE,1))
= (Select convert(char(10),getdate (),1)))
GO
================================
I keep getting a failure message on this telling me that there is a syntax error on the last line by ')'.
Any ideas??
Thanks in advance!
//sse
Sean Engle
Admin/DirIS
ssengle@bswusa.com