Click here to Skip to main content
15,905,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to watch sql columns in table, which has been recently changed with out using last modified date

Could you help me to sql query for latest changes.

original table:

S.No Employee id       First Name   Last Name   Address 1
1    00007          J           Siva        East st
2    020007         G           Moorthy         West street
3    300007         gan         thanu           East st
4    100007             esh         Moor            West street


modified table

S.No Employee id       First Name   Last Name   Address 1
1    00007          Jun        Siva      East st
2    020007         Gon    Moorthy   West street
3    300007         gan         thanu           East st
4    100007             esh         Moor            West street



so i need to fetch only below 2 rows.

S.No Employee id       First Name   Last Name   Address 1
1    00007          Jun        Siva      East st
2    020007         Gon    Moorthy   West street


What I have tried:

original table:

<pre>	S.No Employee id       First Name	Last Name	Address 1
	1    00007	        J	        Siva    	East st
	2    020007     	G	        Moorthy	        West street
	3    300007	        gan	        thanu	        East st
	4    100007 	        esh	        Moor	        West street


modified table

S.No Employee id       First Name   Last Name   Address 1
1    00007          Jun        Siva      East st
2    020007         Gon    Moorthy   West street
3    300007         gan         thanu           East st
4    100007             esh         Moor            West street



so i need to fetch only below 2 rows.

S.No Employee id       First Name   Last Name   Address 1
1    00007          Jun        Siva      East st
2    020007         Gon    Moorthy   West street
Posted
Updated 17-Apr-18 7:41am

Not sure if I understand your question correctly. But if you have both tables, the modidied and the original, you can perhaps use EXCEPT operator

For example
SQL
SELECT SNo, EmployeeId, FirstName,LastName, Address
FROM ModifiedTable
EXCEPT
SELECT SNo, EmployeeId, FirstName,LastName, Address
FROM OriginalTable
 
Share this answer
 
Comments
Vinodh Muthusamy 18-Apr-18 1:22am    
i will be having only 1 table.
Wendelius 18-Apr-18 23:49pm    
In that case if you don't want to add any change info such as timestamp or something else to the table, you can create a new table to log changes in the employee table and store the changes using a trigger on the employee table.

Have a look at Working with Triggers[^]
If you hadn't defined your table with a row of timestamp there is no way to do it...
 
Share this answer
 

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