Click here to Skip to main content
14,879,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
ALTER trigger [dbo].[tri_memberLoginUpdate] on [dbo].[tbl_advisor_registration]
for update
as
declare @advId bigint;
declare @Name varchar(100);
declare @password varchar(100);
declare @status bigint;

select @advId=i.advisor_id from inserted i;
select @name=i.advisor_username from inserted i;
select @password=i.advisor_password from inserted i;
set @status=2;

update tbl_login set username=@name,password=@password,status=@status where user_Id=@advId and status=2



im using this trigger ,but its updating only single rows..
Posted

SQL
ALTER TRIGGER [dbo].[tri_memberLoginUpdate]
ON [dbo].[tbl_advisor_registration]
FOR  UPDATE
AS

    UPDATE T
    SET    t.USerName = i.advisor_username, t.Password =  = i.advisor_password
    FROM   tbl_login t
           INNER JOIN INSERTED i
                ON  i.advisor_id = t.User_id
                    AND t.Status = 2

i don't think there is a loop needed hope this solves your problem
   
because here
where user_Id=@advId
you are only passing single id not multiple id
   
Comments
King Fisher 12-Nov-13 8:32am
   
how to pass multiple id
You have to use while loop within the Trigger to update or insert multiple records

For more visit here...


while-loop-inside-a-trigger-to-loop-through-all-the-columns-of-table-in-sql[^]
   
yes @Rakesh Meel is right only with looping you can provide multiple id
   

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