Well of cause the trick is to understand the inserted and deleted system tables and then avoiding the recursive loop.
It can probably be done alot nicer, but this is the first version i came up with :)
create table mytable(
id int IDENTITY(1,1) PRIMARY KEY,
columnA nvarchar(5) ,
columnB nvarchar(5)
)
GO
CREATE TRIGGER [dbo].[myname]
ON [dbo].[mytable]
FOR UPDATE
AS
BEGIN
declare @targets table(
id int
)
insert into @targets(id)
(select id from deleted)
declare @id int
set @id = (select top 1 id from @targets)
while exists(select * from @targets)
BEGIN
declare @a nvarchar(5)
declare @b nvarchar(5)
set @a = (select columnA from deleted where id = @id)
set @b = (select columnB from deleted where id = @id)
if (Update(columnA) or Update(columnB)) and @a <> @b
begin
update mytable
set columna = columnb
where id = @id
end
delete from @targets where id = @id;
set @id = (select top 1 id from @targets)
END
END
go
insert into mytable(ColumnA, ColumnB)
values('abc','bcd')
update mytable
set columna = 'gef'
where id = 1
select * from mytable
drop table mytable