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 |
|
Leont
Starting Member
2 Posts |
Posted - 2008-07-09 : 07:46:06
|
| Bonjour, J'ai un soucis avec un trigger que j'ai écrit.Voici le code:CREATE TRIGGER ETL2UPDATE ON [Mmm].[Products] AFTER UPDATEASIF UPDATE(IsActive)BEGIN DECLARE @Code varchar(8) SET @Code =(SELECT Code FROM inserted)UPDATE [Matis].[Products] SET Status_Id=1 WHERE Product_Code=@CodeENDIsActive et Code: sont des champs de la table [Mmm].[Products],Status_Id: est un champ de la table [Matis].[Products]Il ne fonctionne pas quand je fais une mise à jour sur la table [Mmm].[Products]. Je n'ai même de message d'erreur. Est-ce que quelqu'un peut me dire ce qui ne va pas? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-09 : 07:50:34
|
Sorry . . . whatever language is that, i don't understand at all. I only understand T-SQL and this is the part that is wrong.Your trigger need to handle updates in set-basedDECLARE @Code varchar(8)SET @Code =(SELECT Code FROM inserted)UPDATE pSET Status_Id=1FROM [Matis].[Products] pINNER JOIN inserted i ON p.Product_Code = i.CodeWHERE Product_Code=@Code
KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Leont
Starting Member
2 Posts |
Posted - 2008-07-09 : 08:29:06
|
| In fact I have 2 tables,updatine a filed in the first one make fire the trigger in the seconde one. It works as I posted it. |
 |
|
|
|
|
|