You are here: SQL Server 2005: TRIGGER AFTER INSERT « MsSQL Server « IT news, forums, messages
SQL Server 2005: TRIGGER AFTER INSERT

Posted by R.A.M. on 03/22/06 20:54

Hello,
I am learning SQL Server 2005.
I need to create a trigger which increments number of book's
publications:

CREATE TRIGGER InsertPublication
ON Publications
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Num smallint
SET @Num = SELECT NumPublications FROM Books WHERE ISBN IN
(SELECT ISBN FROM inserted);
UPDATE Books
SET NumPublications = @Num + 1
WHERE ISBN IN
(SELECT ISBN FROM inserted);
END

Unfortunately I receive a message:

Incorrect syntax near the keyword 'SELECT'.

Could you explain me please how to correct the code?
I am new to SQL Server.
Thank you very much.
/RAM/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация