sql server,insert into 批量插入问题

  • o
    opensesame
    insert into tableA SELECT field01, field02, ... FROM tableB
    where ...


    如果tableA 和 tableB 都是sql server的表,就算不在同一库,都没什么问题
    但是现在的tableB 是导入excel的一个sheet,实际就是from [tableB$]


    提示错误是没有权限更新,怎么处理呢?




    用BULK INSERT能解决,但是BULK INSERT的时候不能where条件,我想试着用insert into加个where来插入
  • I
    IAmThrilling
    b是读就行了啊,为啥提示没权限 iOS fly ~
  • o
    opensesame
    是啊,我怀疑是
    insert into tableA没有权限

    asp的页面,读取excel用的conn1,所以可能这里写的有问题,
    conn.Execute 吧,读不到excel的sheet
    conn1.Execute吧,就是没权限
  • m
    manhere
    随便弄个navicat直接用向导就能操作了
  • z
    zsdicky
    不记得了,是如何读excel的
  • c
    cyberkiller
    非常讨厌从excel导入数据
  • o
    opensesame
    没办法,数据源是从金蝶导出的,操作的人只会在页面上点点按钮,而我又只会古老的asp

    可能还是conn的用法不对,但是一句sql里怎么同时用两个conn呢HiPDA·NG
  • n
    ngok
    先用bulk insert插入一张临时表,再从临时表select where
  • b
    bigbear3000
    回复1#opensesame
    直接从excel复制到一个新表再用这个语句不就可以了,复制后在sqlserver manage粘贴就行、如果数据多等等就行 iOS fly ~
  • N
    NetCobra
    先建一个临时表c,bulk insert到临时表c,再从临时表c用where查询插入到表a