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 |
|
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 Keyi want to create a trigger that don't allows me to A PERSONNEL to HAVE MORE THAN 2 PARTICIPANTSI create a trigger:CREATE TRIGGER Mon_Trigger ON Participants AFTER INSERT,UPDATEAS declare @nbre_Part int ,@nbre_Parti intBEGINselect @nbre_Part=count(*)from Insertedselect @nbre_Part=count(*)from updatedif ( @nbre_Part > 2 )BeginROLLBACKRAISERROR [Nombre Limite dépassé!!!!!!]ENDif ( @nbre_Parti > 2 )BeginROLLBACKRAISERROR [Nombre Limite dépassé!!!!!!]ENDENDGOwhen i excute,this message appears:Msg 102, Level 15, State 1, Procedure Mon_Trigger, Line 19Syntaxe incorrecte vers 'Nombre Limite dépassé!!!!!!'.[size="7"][/size]please help methks |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-08-10 : 12:00:35
|
try this...CREATE TRIGGER Mon_Trigger ON Participants AFTER INSERT,UPDATEAS declare @nbre_Part int ,@nbre_Parti intBEGINselect @nbre_Part=count(*)from Insertedselect @nbre_Part=count(*)from updatedif ( @nbre_Part > 2 )BeginROLLBACKRAISERROR ('Nombre Limite dépassé!!!!!!',10,1); ENDif ( @nbre_Parti > 2 )BeginROLLBACKRAISERROR ('Nombre Limite dépassé!!!!!!',10,1); ENDENDGO-------------------------R..http://code.msdn.microsoft.com/SQLExamples/http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx |
 |
|
|
|
|
|
|
|