不管是把Sql Server表的资料插入Excel:
Insert Into OpenRowSet('Microsoft.Jet.OLEDB.4.0','Excel 5.0;hdr=Yes;DataBase=C:\test.xls',test$)
select * from T_test
还是把Excel的资料插入Sql Server表:
Insert Into T_test 
select * from OpenRowSet('Microsoft.Jet.OLEDB.4.0','Excel 5.0;hdr=Yes;DataBase=C:\test.xls',test$)

都有可能会遇见字段混乱的问题,
即:Sql Server表和Excel的字段顺序不一样!

其实,出现这样的问题,是对OpenRowSet 使用不甚了解引起的!
hdr = Yes 表示Excel内容第一行作为内容字段而不是字段列,
所以,把 hdr = Yes 改为 hdr = No 即可!

相关文章:

  • 2021-11-22
  • 2022-02-19
  • 2022-12-23
  • 2021-05-14
  • 2021-12-02
  • 2022-01-11
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2021-06-05
  • 2021-04-15
  • 2021-05-05
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案