Click here to Skip to main content
16,018,637 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm using sql server.

there's a table with some fields: column1, column2, ...

the user has access to column1, and he can update it's content.
Now I want to create a trigger to copy the new content of column1 to column2 automatically.

e.g. set column2 = column1 AFTER UPDATE (column1)

I've created a trigger on the table. in the trigger I use the code bellow:

SQL
CREATE TRIGGER [dbo].[mytrigger]
   ON  [dbo].[mytable]
   AFTER UPDATE
AS
IF UPDATE(userName)
BEGIN
    
    SET NOCOUNT ON;
    
    -- HERE I SHOULD WRITE A CODE TO COPY NEW DATA OF COLUMN1 TO COLUMN2 !! :-??

END


WHAT code should I use instead of the comment ??

I'll appreciate any help.
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900