Hi RichardSa,
Refer below query.
CREATE TABLE Users2
(
Id INT
,email VARCHAR(50)
,Name VARCHAR(50)
,CreatedBY VARCHAR(60)
,LastLogin VARCHAR(70)
)
INSERT INTO Users2 VALUES('1', 'richard@gmail.com', 'RichardSa', 'richard@gmail.com', '14-Feb-23 8:05AM')
INSERT INTO Users2 VALUES('2', 'sammy@gmail.com', 'RichardSa', 'richard@gmail.com', '17-Feb-23 1:35PM')
INSERT INTO Users2 VALUES('3', 'manny@gmail.com', 'RichardSa', 'richard@gmail.com', '20-Feb-23 6:48PM')
INSERT INTO Users2 VALUES('4', 'mike12@gmail.com', 'Mikey', 'mike12@gmail.com', '20-Feb-23 9:14PM')
INSERT INTO Users2 VALUES('5', 'okon@yahoo.com', 'Mikey', 'mike12@gmail.com', '20-Feb-23 11:58PM')
--EXEC Update_ChildUserData 'abc@gmail.com','abc','richard@gmail.com','RichardSa'
ALTER PROCEDURE Update_ChildUserData
@Email VARCHAR(50),
@Name VARCHAR(50),
@OldEmail VARCHAR(50),
@OldName VARCHAR(50)
AS
BEGIN
UPDATE users2
SET CreatedBY = @Email
,Name=@Name
WHERE CreatedBY=@OldEmail and Name=@OldName
UPDATE users2
SET email = @Email
,Name=@Name
WHERE email=@OldEmail or Name=@OldName
END
Screenshot
Id |
email |
Name |
CreatedBY |
LastLogin |
1 |
abc@gmail.com |
abc |
abc@gmail.com |
14-Feb-23 8:05AM |
2 |
sammy@gmail.com |
abc |
abc@gmail.com |
17-Feb-23 1:35PM |
3 |
manny@gmail.com |
abc |
abc@gmail.com |
20-Feb-23 6:48PM |
4 |
mike12@gmail.com |
Mikey |
mike12@gmail.com |
20-Feb-23 9:14PM |
5 |
okon@yahoo.com |
Mikey |
mike12@gmail.com |
20-Feb-23 11:58PM |