Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kirkeby
Yak Posting Veteran
57 Posts |
Posted - 2002-09-04 : 13:01:37
|
I have created the below trigger. When executed from QA it runs fine, sending the email, etc. When executed as a trigger off the ReqCommon table I get the following error:The CREATE TABLE statement is not allowed within a trigger.What is it about this trigger that is causing the problem? BTW, the sproc being used to send the email does indeed send in HTML format.Thanks for any help! CREATE TRIGGER Survey on dbo.ReqCommonFOR UPDATEASset nocount onDECLARE @RequesterEmail varchar(60)DECLARE @RequesterName varchar(60)DECLARE @RequestID intDECLARE @RequestType char(1)DECLARE @ReqType varchar(10)DECLARE @CompletedDate datetimeDECLARE @Status intDECLARE @msg varchar(8000)DECLARE @AllRecipients varchar(500)IF EXISTS(SELECT Request_ID FROM inserted)BEGINSET @RequesterEmail = (SELECT Requester_Email FROM inserted)SET @RequesterName = (SELECT Requester_Name FROM inserted)SET @RequestID = (SELECT Request_ID FROM inserted)SET @CompletedDate = (SELECT Completed_Date FROM inserted)SET @RequestType = (SELECT Request_Type FROM inserted)SET @Status = (SELECT Current_Status_ID FROM inserted)SET @AllRecipients = @RequesterEmail-- + ';' + 'vinsonsm@bp.com'IF @RequestType = 'S' BEGIN SET @ReqType = 'Scripting' ENDIF @RequestType = 'T' BEGIN SET @ReqType = 'Testing' ENDSET @msg = '<html><body><FORM name="frmSurvey" action="http://dboas.bpweb.bp.com/email/Email.asp"><p align="left"><a href="http://dboas.bpweb.bp.com"><img src="http://dboas.bpweb.bp.com/images/DBOASLogo.gif" border="0"></a></p><font face=verdana size=2><p align="left"><B>Request ID: ' + CAST(@RequestID as varchar(10)) + ' Requester Name: ' + @RequesterName + '</b></font><BR><BR><p align="left"><BR><font face="verdana" size="3"><b>Your request has been completed by the DBO Application Scripting team.</b></font><p align="left" bgcolor="#c0c0c0"><font face="verdana" size="2"><B>What was your overall experience regarding Scripting?</B></font></p><p align="left"><font face="verdana" size="2"><input type="radio" name="scripting" value="1" tabindex="1"> <B>Service Not Associated with my request</B><BR><input type="radio" name="scripting" value="2" tabindex="2"> <B>Poor</B><BR><input type="radio" name="scripting" value="3" tabindex="3"> <B>Fair</B><BR><input type="radio" name="scripting" value="4" tabindex="4"> <B>Good</B><BR><input type="radio" name="scripting" value="5" tabindex="5"> <B><I>Excellent!</I></B></font></p><p align="left" bgcolor="#c0c0c0"><font face="verdana" size="2"><B>Comments:</B></font></p><p align="left" width="100%"><font face="verdana" size="2"><textarea name="comments" rows="5" cols="80" tabindex="16"></textarea></font></p><p align="left"><input type="submit" name="submit" value="Submit" tabindex="17"></p><BR><BR></form></body></html>'IF @CompletedDate IS NOT NULL AND @RequestType = 'S' OR @RequestType = 'T' AND @Status = 8 OR @Status = 11 OR @Status = 12 or @Status = 16BEGINEXEC master..sp_sendSMTPmail @RequesterEmail, 'Your request has been completed by DBO Application Scripting', @msg, @Importance=2, @HTMLFormat=1ENDENDLisa KirkebyBPkirkeblm@bp.comSQL 7.0, NT 4.0 (1381), CP 1252 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-09-04 : 13:10:01
|
| look at master..sp_sendSMTPmailIt probably has a create table #... statement in it which is invalid.You may be able to round it be creating a new version with a select into instead. (works on at least some versions).I wouldn't advise it because it's probably a bug that it;s allowed.Better to put your request into a table then have a scheduled task that sends the emails (then you can still run the application if the email service is down.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
kirkeby
Yak Posting Veteran
57 Posts |
Posted - 2002-09-04 : 14:36:27
|
| Thank you! Your suggestion to dump it into a table and use a task (I'm using a SQL job) is working great! Thank you!Lisa KirkebyBPkirkeblm@bp.comSQL 7.0, NT 4.0 (1381), CP 1252 |
 |
|
|
|
|
|
|
|