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/
[Back to original message]
|