sipadu (7/29/2013)
I have an examplecreate TRIGGER InsertarPeriodoForUpdate
ON dbo.calificacion_IQA
for update
AS
BEGIN
SET NOCOUNT ON;
declare @id int
declare @mes int
select @mes=mes_calificadcion, @id = id_calificacion_iqa from updated
if @mes=1 or @mes = 2 or @mes = 3
begin
Update dbo.calificacion_IQA
set cuarto = 1
where id_calificacion_iqa=@id
end
if @mes=4 or @mes = 5 or @mes = 6
begin
Update dbo.calificacion_IQA
set cuarto = 2
where id_calificacion_iqa=@id
end
if @mes=7 or @mes = 8 or @mes = 9
begin
Update dbo.calificacion_IQA
set cuarto = 3
where id_calificacion_iqa=@id
end
if @mes=10 or @mes = 11 or @mes = 12
begin
Update dbo.calificacion_IQA
set cuarto = 4
where id_calificacion_iqa=@id
end
END
GO
Not only is this thread 9 years old your code is broken on a number of levels. There is no "updated" in triggers in sql server. And even worse is that your code will not support multiple rows. The logic posted is entirely to flawed to even have a chance at being correct.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/