Share via

positive edge

laroussi derbel 41 Reputation points
2021-10-13T12:46:02.173+00:00

Hi every one , i wanted to build a positive edge with a variable that i named @Prozessstart. this is my programm

Create TRIGGER [dbo].[tinsert]
ON [dbo].[TBL_LiveData]
AFTER UPDATE
As
DECLARE @Prozessstart integer;
Prozessstart = 0
IF (SELECT dbo.TBL_LiveData.Value
FROM dbo.TBL_LiveData
WHERE dbo.TBL_LiveData.ConfigID = 251) =0
BEGIN
@Prozessstart := 0 ;
END
IF ((SELECT dbo.TBL_LiveData.Value
FROM dbo.TBL_LiveData
WHERE dbo.TBL_LiveData.ConfigID = 251) =1) AND @Prozessstart < 1
BEGIN
@Prozessstart <= @Prozessstart + 1
INSERT INTO ....
END

but i recieve this error message ,

Message 102, level 15, status 1, procedure tinsertV9, line 7 [Batchstart line 7].

Incorrect syntax near "@processstart".

Message 102, level 15, status 1, procedure tinsertV9, line 12 [Batchstart line 7].

Wrong syntax near "@processstart".

Message 102, level 15, status 1, procedure tinsertV9, line 18 [Batchstart line 7].

Wrong syntax near "@processstart".

Message 102, level 15, status 1, procedure tinsertV9, line 26 [Batchstart line 7].

Incorrect syntax near "END".

can anyone please help me ?

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2021-10-13T12:57:35.73+00:00

Try removing ':' and '<' and use SET:

set @Prozessstart = 0
. . .
set @Prozessstart = @Prozessstart + 1

(or set @Prozessstart += 1).

You also have Prozessstart = 0 which probably must be set @Prozessstart = 0.

And something is wrong before the END line.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.