sql - Update existing records table with ID of foreign key table -
i have following tables:
and
i added [history table id] column , added foreign key reference history table. has happen is, value of [history table id] column has updated id value of history table. have been able right 2 entries, entries have id of diary table in description column of history table. query below accomplishes that:
update diary set [history table id] = history.id history (nolock) [lookup table ha] = 7 , [lookup table has] = 19 , description 'diary item (%' , patindex('%)%', description) > 13 , dairy.id = substring(description, 13, patindex('%)%', description)-13)
is there way rest can updated @ all? can't head around this.
thanks in advance.
update:
please see below updated table shots: problem in updating , joining lies:
as have mentioned in comment, "issuenumber same. globalid same in both tables." work fine:
update diary set [history table id] = history.id history (nolock) diary.[global id] = history.[global id] , diary.issuenumber = history.issuenumber
Comments
Post a Comment