如何在运行时在excel中添加列并将其上传到数据库中. [英] How to add column in excel at run time while uploading it into the database.

查看:60
本文介绍了如何在运行时在excel中添加列并将其上传到数据库中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时在excel中添加列,同时将其上传到数据库中,而不是手动添加列然后上传?
请提供必要的全面帮助.


谢谢.

How to add column in excel at runtime while uploading it into the database,instead of adding the column manually and then uploading?
pls,provide needfull help.


Thank you.

推荐答案

不确定您想要什么...

可能您这样使用SQL查询:
Not sure what you want...

Probably you use SQL query like this:
INSERT INTO ... SELECT ... FROM [`Sheet1`]



试试这个(更新后):



Try this (after update):

INSERT INTO YourTable (ExcelField1, ExcelField2, ..., ExcelFieldN, MyMonth, MyYear)
SELECT DT.*
FROM (SELECT *, MONTH(GETDATE()) AS MyMonth, YEAR(GETDATE()) AS MyYear
      FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database:=FullPathToFile.xls', ' SELECT * FROM [Sheet1


') AS DT



这是您想要的吗?



Is this what you want?


这篇关于如何在运行时在excel中添加列并将其上传到数据库中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆