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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Msg 102, Level 15, State 1, Procedure Mon_Trigger,

Author  Topic 

Tunisien86
Starting Member

2 Posts

Posted - 2009-08-10 : 11:52:35
have 2 tables:
-Personnel : IDENT primary key
-Participants:IDENTPART primary key IDENT Foreign Key
i want to create a trigger that don't allows me to A PERSONNEL to HAVE MORE THAN 2 PARTICIPANTS
I create a trigger:
CREATE TRIGGER Mon_Trigger
ON Participants
AFTER INSERT,UPDATE
AS
declare @nbre_Part int ,@nbre_Parti int
BEGIN
select @nbre_Part=count(*)
from Inserted
select @nbre_Part=count(*)
from updated
if ( @nbre_Part > 2 )
Begin
ROLLBACK
RAISERROR [Nombre Limite dépassé!!!!!!]
END
if ( @nbre_Parti > 2 )
Begin
ROLLBACK
RAISERROR [Nombre Limite dépassé!!!!!!]
END
END
GO
when i excute,this message appears:
Msg 102, Level 15, State 1, Procedure Mon_Trigger, Line 19
Syntaxe incorrecte vers 'Nombre Limite dépassé!!!!!!'.[size="7"][/size]
please help me
thks

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-10 : 12:00:35
try this...


CREATE TRIGGER Mon_Trigger
ON Participants

AFTER INSERT,UPDATE
AS
declare @nbre_Part int ,@nbre_Parti int
BEGIN
select @nbre_Part=count(*)
from Inserted
select @nbre_Part=count(*)
from updated
if ( @nbre_Part > 2 )
Begin
ROLLBACK
RAISERROR ('Nombre Limite dépassé!!!!!!',10,1);
END
if ( @nbre_Parti > 2 )
Begin
ROLLBACK
RAISERROR ('Nombre Limite dépassé!!!!!!',10,1);
END
END
GO






-------------------------
R..
http://code.msdn.microsoft.com/SQLExamples/
http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx
Go to Top of Page
   

- Advertisement -