declare @tbl table (TBLID int identity(1,1),ID int,patientName varchar(10),age int,city varchar(100),Mobile int)
insert @tbl(ID,patientName,age,city,Mobile)
select 1,'Ramesh',20,'HYD',12345678 union all
select 1,'Ramesh new',20,'HYDERABAD ' ,12345678 union all
select 1,'Ramesh new',20,'HYDERABAD ' ,87654321
select * from @tbl
TBLID, ID, patientName , age , city , Mobile
1 , 1 , Ramesh , 20 , HYD , 12345678
2 , 1 , Ramesh , 24 , HYD , 12345678
3 , 1 , Ramesh new, 20 , HYDERABAD , 87654321
i want output as mentioned below format which columns data got changed
input params @FromTBLID,@ToTBLID
if i will pass @FromTBLID=1,@ToTBLID=3 then it will display like below
Columns, OLDDATA , NEWDATA
patientName ,Ramesh ,Ramesh new
City ,HYD , HYDERABAD
Mobile ,12345678 ,87654321
if i will pass @FromTBLID=1,@ToTBLID=2 then it will display like below
Columns, OLDDATA , NEWDATA
age , 20 ,24