Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to update similar tables

Status
Not open for further replies.

fikir

Programmer
Jun 25, 2007
86
I have two tables which are similar

declare @tbl table (id int primary key,
name varchar(100))
declare @tbl2 table (id int primary key,
name varchar(100),
flag varchar(10))

insert into @tbl select 1, 'abc'
union all select 2, 'bb'

insert into @tbl2 select 1, 'abc', 'no'
union all select 2, 'bb', 'no'

@tbl2 ia a copy of @tbl except @tbl2 has extra column 'flag'

my question is if any of data is changed in @tbl, I should get which column changed and update it to @tbl2,

both tables could have upto 72 columns,

what is the eaiest way to get the changed coulmn and update it to @tbl2

Thanks
 
look up "triggers" in Books Online

< M!ke >
Your right to an opinion does not obligate me to take you seriously.
- Winston Churchill
 
This is not a situation where we can use triggers, I am using this for a data conversion purpose,

I am trying to convert a data from oracle to sql server,

my problem, after first load (data conversion), the oracle data might be changed, and I have to track each change and update it to my sql server

example
first time I load from @tbl

id name
1 'abc'
2 'bb'

to @tbl2

after some day the data might be changed

id name
1 'abc'
2 'cc'

I have to update this to @tbl2

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top