向 Excel 文件添加 2 个额外列

发布于 2024-08-11 19:08:02 字数 449 浏览 2 评论 0原文

由于 Microsoft ODBC Excel 驱动程序不支持 ALTER TABLE/DELETE FROM(/UPDATE?) 语句,因此我使用其他方法在正确的位置获取正确的数据。

我在将 2 列添加到 Excel 工作表时仍然遇到一个问题。

有人告诉我使用:

SELECT *, newcol1, newcol1 INTO newExternalSheet FROM thisSheet;

这不起作用,因为驱动程序抱怨不存在的列。嗯,它并没有完全告诉我这一点,但它给出了一些关于参数丢失的模糊错误消息。

相信我,没有缺少任何参数,它还会针对这种情况给出错误消息。

SQL error: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 2.

Since the Microsoft ODBC Excel Driver doesn't support ALTER TABLE/DELETE FROM(/UPDATE?) statements, I'm using alternative ways of getting the right data in the right place.

I still have one problem with getting 2 columns added to an excel sheet.

Someone told me to use:

SELECT *, newcol1, newcol1 INTO newExternalSheet FROM thisSheet;

This doesn't work, since the driver complains about non-existant columns. Well, it doesn't exactly tell me that, but it gives some vague error message about parameters missing.

Believe me, there are no parameters missing, it also gives that error message for this kind of situations.

SQL error: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵强ㄟ 2024-08-18 19:08:02

看起来当您将 newcol1 传递给数据库时,它认为您正在指定参数或列名。此外,Excel 有时会感到困惑,因此将整个查询包装在 Select * From (...) X 语句中会有所帮助。为什么不使用:

Select * From (SELECT *, '' As `newcol1`, '' AS `newcol2` FROM thisSheet) X;

It looks like when you pass newcol1 to your database, it think you are specifying either a paramater or a column name. Also, Excel sometimes gets confused, so it helps to wrap your entire query in a Select * From (...) X statement. Why not use:

Select * From (SELECT *, '' As `newcol1`, '' AS `newcol2` FROM thisSheet) X;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文