請教各位大哥,
目前我有個難題, 如下
有一個資料庫A內, 有資料表a, 裡頭的欄位分別是
[Identity][Key1][Key2][Key3][Value][DateTime]
資料表 a 經過整理, Key1+Key2+Key3 沒有重複的資料
另外一個資料庫B內, 有資料表b, 裡頭的欄位也是
[Identity][Key1][Key2][Key3][Value][DateTime]
但是, Key1+Key2+Key3 可能會有重複的資料,
( Key1+Key2+Key3重複時, Value和DateTime可能重複,也可能不重複)
現在要做的動作是
把資料庫 B 內資料表 b 的資料, 新增加到資料庫 A 的資料表 a 上
(1) 如果b中有個 Key1+Key2+Key3, 而a中沒有 -> 將 b 的資料新增到 a 中
 (2) 如果b中有個 Key1+Key2+Key3, 而a也有 Key1+Key2+Key3 ->
   --> 比較 b 的[DateTime] 和 a 的 [DateTime]
   --> 若是 b 日期時間比較新,
   -- >則 Update a 的 [Value][DateTime] 成為 b 的 [Value][DateTime]
 (3) 若 b 中有重複的 Key1+Key2+Key3, 則只取最新 [DateTime] 的那一個

我想要把這些動作用 SQL Command 做成
我用過 RecordSet, 把資料叫到 VB 來一一判斷
但是資料量大的時候, 這個方法太慢了
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(3) 人氣()