Γειά σας
Προσπαθώ να εκτελέσω το παρακάτω Τ-SQL στην SQL 2000 DB και παίρνω αυτό το μήνυμα :
[Microsoft][ODBC SQL Server Driver][SQL Server]'CREATE TRIGGER' must be the first statement in a query batch.
CREATE
TRIGGER [trg_UpdateVoteCountOnDelete] ON [dbo].[PollResults] AFTER DELETE
AS
DECLARE @PollId int,
@AnswerId
int
BEGIN
select @PollId=pollid, @AnswerId=pollchoice from deleted
update pollanswers
set answercount=(select count(*) from pollresults where pollid=@PollId and pollchoice=@AnswerId) where pollid=@PollId and answerid=@AnswerId
update pollquestions
set answercount=(select count(*) from pollresults where pollid=@PollId) where pollid=@PollId
END
RETURN
Για ποιό λόγο ξέρει κάποιος;