There's a database table that has an update trigger. Whenever a column is updated, one of its columns is automatically calculated.
I have tweaked the trigger and I'd like to run it on all of the rows again. In SQL Server Management Studio, if I choose "Edit Top 200 Rows" on my table and edit one of the rows, the update trigger works. But when I write a query like:
UPDATE MyTable
SET SomeIrrelevantColumn = 0
the trigger doesn't work, the column that is supposed to be calculated by the trigger stays the same.
How can I run the trigger manually on all the rows?
Edit: Here's the trigger:
USE [MY_DATABASE]
GO
/****** Object: Trigger [dbo].[MY_TABLE_AUER] Script Date: 04/24/2013 00:05:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[MY_TABLE_AUER]
ON [dbo].[MY_TABLE]
AFTER UPDATE
AS
DECLARE @UPD_COLUMN_A int,
@INS_COLUMN_A int,
@UPD_COLUMN_B int,
@UPD_COLUMN_C varchar(255),
@UPD_COLUMN_D varchar(255),
@UPD_COLUMN_E int,
@UPD_COLUMN_F datetime
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @UPD_COLUMN_A = _Column_A,
@UPD_COLUMN_B =_Column_B,
@UPD_COLUMN_C = COLUMN_C,
@UPD_COLUMN_D = [Column_D]
FROM DELETED;
IF @UPD_COLUMN_D not like '%SomeString%'
BEGIN
SELECT @INS_COLUMN_A = _Column_A
FROM INSERTED;
IF @UPD_COLUMN_A != @INS_COLUMN_A
BEGIN
SELECT @UPD_COLUMN_E = MAX([_Column_B]),
@UPD_COLUMN_F = MAX([_Column_G])
FROM MY_TABLE
WHERE COLUMN_C = @UPD_COLUMN_C
AND [Column_D] LIKE '%SomeString%';
UPDATE MY_TABLE
SET COLUMN_E = @UPD_COLUMN_E,
COLUMN_F = @UPD_COLUMN_F
WHERE [_Column_B] = @UPD_COLUMN_B;
UPDATE MY_TABLE
SET COLUMN_H = @UPD_COLUMN_B
WHERE [_Column_B] = @UPD_COLUMN_E;
END
END
END