sql server - Database based table with manually added column - maintaining values positions -
let's consider simple excel table associated sql server's table:
id some_data 0 1 b 2 c
i'd extend manually added column (not present in sql server's table):
id some_data my_column 0 some_data_for_0 1 b some_data_for_1 2 c some_data_for_2
however, when source data changed (rows inserted / deleted / updated) relation between my_column , id column not preserved. example, when new row (3, d) added:
id some_data my_column 0 some_data_for_0 1 b some_data_for_1 2 c 3 d some_data_for_2
is there excel built-in solution allow me specify how my_column rows should ordered in relation id column or need implement myself using vba?
you use order clause in sql statement, that's not reliable. reliable way store additional data in own table , use formula relate sql data.
on separate worksheet, put
id my_column 0 some_data_for_0 1 some_data_for_1 2 some_data_for_2
now in column adjacent sql data, put
=iferror(vlookup([@id],tbladdtlinfo,2,false),"")
however sql data sorted, additional info in right row. assumes made additional info list table , named tbladdtlinfo.
if want fancy, can write code in change event looks non-formulas in column. if formula gets on written, grab new data, add (or update) additional info table, , restore formula. can type data in row, maintain integrity moving different table.
Comments
Post a Comment