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 |
|
grueneic
Starting Member
3 Posts |
Posted - 2002-05-29 : 10:09:00
|
| Below is a trigger I am working on. I am receiving several errors and do not know how to resolve. One of the Errors is the line that says 'IF @ClearBy IS NULL' There are also other errors with the IF statement. Please help. I am new at this.CREATE Trigger trg_employeesOn dbo.TROUBLEFor UpdateASDeclare @Comment nvarchar(1000)Declare @TechnicianRemarks nvarchar(1000)Declare @ClearBy nvarchar(25)Declare @ClearDate datetimeDeclare @ClearTime datetimeDeclare @Type nvarchar(50)Select @Comment = Comment FROM INSERTEDSelect @TechnicianRemarks = Resolution FROM INSERTEDSelect @ClearBy = ClearBy FROM INSERTEDSelect @ClearDate = ClearDate FROM INSERTEDSelect @ClearTime = ClearTime FROM INSERTEDSelect @Type = Type FROM INSERTED/*Check to see if the ClearBy field is NULL. We only want to send an emailif the ClearByField is NOT NULL.*/IF @ClearBy IS NULL BEGIN --do nothing ENDELSE --Now Check to see if the ticket is a Service Order (SO) or a Trouble Ticket (TR) IF @Type = 'SO' BEGIN END |
|
|
Kevin Snow
Posting Yak Master
149 Posts |
Posted - 2002-05-29 : 10:21:51
|
| IF @ClearBy IS NULL BEGIN --do nothing END You may need parenthesesIF NOT(@ClearBy IS NULL )Also, the SQL Parser does not allow empty BEGIN END blocksEliminate them, or put in a temporary 'filler' step.BEGIN Select @ClearBYEND |
 |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2002-05-29 : 10:23:19
|
SQL is looking for a statement between the BEGIN and END tags. A comment won't work. Change you code to this: CREATE Trigger trg_employees On dbo.TROUBLE For Update AS Declare @Comment nvarchar(1000) Declare @TechnicianRemarks nvarchar(1000) Declare @ClearBy nvarchar(25) Declare @ClearDate datetime Declare @ClearTime datetime Declare @Type nvarchar(50) Select @Comment = Comment FROM INSERTED Select @TechnicianRemarks = Resolution FROM INSERTED Select @ClearBy = ClearBy FROM INSERTED Select @ClearDate = ClearDate FROM INSERTED Select @ClearTime = ClearTime FROM INSERTED Select @Type = Type FROM INSERTED /*Check to see if the ClearBy field is NULL. We only want to send an email if the ClearByField is NOT NULL. */ IF @ClearBy IS NOT NULL --Now Check to see if the ticket is a Service Order (SO) or a Trouble Ticket (TR) IF @Type = 'SO' BEGIN ...statement here...END |
 |
|
|
grueneic
Starting Member
3 Posts |
Posted - 2002-05-29 : 10:25:14
|
| THANK YOU. IT NOW WORKS |
 |
|
|
|
|
|