数据库表设计了2张,一个问题表,一个答案表,根据编号关联
怎么就把Excel模板里面有问题和答案拆分开,点导入的时候,同时插入到两张表中呢,求解

解决方案 »

  1.   

    从excel读出来,插入到数据库中,两张表时注意一下事务,可以在存储过程加入事务,也可以用ado.net的事务http://blog.csdn.net/thinkingforever/article/details/193814
      

  2.   

    在 EXCEL 中把问题和答案分成两个表,注意拆分出去的那个表中要把编号复制过去.
    直接在SQL里用链接服务器与EXCEL连接,分别导入两张表. 
    exec sp_addlinkedserver 'sample','','Microsoft.Jet.OLEDB.4.0','e:\tb.xls','','EXCEL 8.0',''
    --第二项可不写,可用excel 或 jet 4.0,
    --第五项可用''或null
    --第七项可用表名,也可不写
    go
    insert into tb1
    select * from sample...[sheet1$]
    insert into tb2
    select * from sample...[sheet2$]
    go
    exec sp_dropserver 'sample','droplogins'