備忘錄_20160105(定位) 修改 回首頁

程式 2018-06-04 15:21:52 1528096912 100
批次新增、批次更新 MS ACCESS, SQL SERVER

批次新增、批次更新 MS ACCESS, SQL SERVER
批次目標 SQL Server MS Access
新增
insert into tb1(序號, 姓名)
select 1,'章大千'
union all
select 2,'小填填'
union all
select 3,'娃哈哈'
      
  1. 先開一暫存資料表 tbBuffer,並從 excel 將資料複製貼上。
  2. insert into tb1(序號, 姓名)
    select 序號, 姓名 from tbBuffer
            
  3. 刪除 tbBuffer
更新
update tb1
set tb1.姓名=(select tbBuffer.姓名 from tbBuffer where tbBuffer.序號=tb1.序號)
where tb1.序號 in (select tbBuffer.序號 from tbBuffer)
      
  1. 先開一暫存資料表 tbBuffer,並從 excel 將資料複製貼上。
  2. update tb1
    inner join tbBuffer on tbBuffer.序號=tb1.序號
    set tb1.姓名=tbBuffer.姓名
            
  3. 刪除 tbBuffer