Hello Forum
I have an original table and data as follows:
CREATE TABLE #tmpTable (
id int,
FirstName varchar(50),
LastName varchar(50),
Email varchar(50),
Department varchar(50),
Salary int)
INSERT #tmpTable VALUES
(6,'RameshTheThird','Babu','******@pramati.co','Politics',15000),
(2,'Daniel','meng','******@stanford.edu','Delivery',20000),
(8,'Sampath','Kumar','******@pramati.co','Advertising',16000),
(7,'Bipul','Kumar','******@pramati.co','Research',14000),
(3,'Muriel',NULL,'******@waterloo.edu','Marketing',13000),
(1,'Basher','armbrust','******@gmail.com','HR',10000),
(4,'Rachel','wendell','******@imaginea.com','Engineering',70000),
(5,'Zach','galifianakis','******@pramati.co','Analyst',87777),
(9,'Anil','Reddy','******@pramati.co','Business',78000),
(10,'Mageswaran','Dhandapani','******@pramati.co','Law',88000)
I then an updated table as follows:
CREATE TABLE #tmpTable (
id int,
FirstName varchar(50),
LastName varchar(50),
Email varchar(50),
Department varchar(50),
Salary int)
INSERT #tmpTable VALUES
(13,'Carlton','Patterson','******@keyloop.co.uk','Data Engineering',80000),
(10,'Mageswaran','Dhandapani','******@pramati.co','Law',88000),
(3,'Muriel','Somebody','******@waterloo.edu','BrickLayer',66000),
(6,'RameshTheThird','Babu','******@pramati.co','Politics',15000),
(4,'Rachel','wendell','******@imaginea.com','Engineering',70000),
(2,'Daniel','Peterson','******@stanford.edu','Scientist',20000),
(5,'Zach','galifianakis','******@pramati.co','Analyst',87777),
(8,'Sampath','Kumar','******@pramati.co','Advertising',16000),
(7,'Bipul','Kumar','******@pramati.co','Research',14000),
(9,'Anil','Reddy','******@pramati.co','Business',78000),
(1,'Basher','armbrust','******@gmail.com','HR',666)
As you can see from the updated table there has been some changes to Department, Salaries and LastName values
I have compiled the following code with varioius leftouterjoin to capture the updates in the second updated table
SELECT
ORIGINALv1.FirstName
,ORIGINALv1.LastName
,ORIGINALv1.Department
,ORIGINALv1.Salary
,UPDATED.Salary
,UPDATED.Department
,UPDATED.LastName
FROM dbo.ORIGINALv1
LEFT OUTER JOIN dbo.UPDATED
ON ORIGINALv1.Salary = UPDATED.Salary
AND ORIGINALv1.Department = UPDATED.Department
AND ORIGINALv1.LastName = UPDATED.LastName
The table names have changed in my code, but the data is the same.
My code doesn't actually show the changes.
Can someone show me how to modify my query to show the changes?