Excel中的SQL查询返回一个值使用两行或两列?

发布于 2024-10-06 09:02:31 字数 409 浏览 0 评论 0原文

我正在运行从 Excel 到 SQL Server 的查询,该查询返回单个值。看起来好像这使用了 Excel 中的两个单元格。这是正确的吗?有办法防止这种情况吗?有没有办法预测Excel是否会使用额外的行或额外的列(我已经看到这两种情况都发生了)?

如果在 Excel 中,我使用“导入外部数据 -> 新数据库查询”,然后在 SQL Server 表上执行 count(),Excel 通常会将结果放在我开始时选择的单元格下方的单元格中执行新查询(不是添加额外的行,而是将值放在那里)。有时,它会在我选择的单元格的列之前插入一个额外的列,并将结果放入与我选择的单元格同一行的新列中。

有没有一种方法可以让 Excel 在与启动查询时选择的单元格相同的单元格中返回值?如果不是,有没有办法预测上述两种情况中哪一种会发生?

谢谢,

恩斯特

I'm running a query from excel to sql server that returns a single value. It seems as if this uses two cells in excel. Is this correct? Is there a way to prevent this? Is there a way to predict whether excel will use an extra row or an extra column (I've seen both happening)?

If, in excel, I use "import external data -> new database query", and then do a count() on an sql server table, excel usually puts the result in the cell underneath the cell which I had selected when starting to do the new query (not adding an extra row, but putting the value there). Sometimes, it will instead insert an extra column before the column of the cell I had selected and put the result in the new column in the same row as the cell I had selected.

Is there a way to have excel return the value in the same cell as the one selected when starting the query? If not, is there a way to predict which of the two scenarios above will happen?

Thanks,

Ernst

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

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

发布评论

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

评论(1

腹黑女流氓 2024-10-13 09:02:31

我终于找到了答案:

取消选中保留列排序/过滤/布局

I finally found the answer:

uncheck preserve column sort/filter/layout

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文