如何阻止MS Access更改我的SQL代码?

问题描述:

我已经在MS Access中编写了一个SQL查询,Access弄乱了它,只是将其显示为图形". 如何阻止它执行此操作?

I've wrote an SQL query in MS Access and Access made a mess of it, only to show it "graphical". How do I stop it from doing this?

如果将SQL保存为QueryDef对象(例如,使用图形查询编辑器),则不会阻止Access更改您的SQL.您还有(至少)两个其他选择:

There's no stopping Access from changing your SQL if you save it as a QueryDef object (ie, using the graphical query editor). You have (at least) two other options:

  1. 在VBA中构建查询
  2. 将查询存储在专用于使用Memo字段存储SQL的查询的表中(这还需要一些VBA来使用SQL并执行它,或将其分配给临时querydef等)

如果需要,您仍然可以使用QBE(示例查询)窗口来最初生成SQL.

You can still use the QBE (query-by-example) window to generate your SQL initially if you want.

此外,如果您有非Jet后端(例如,MS SQL Server),则可以编写传递查询.您失去了图形界面,但获得了在所选后端中编写SQL的所有功能. Access不会重新调整传递查询的格式.

Also, if you have a non-Jet backend (MS SQL Server, for example) you can write pass-through queries. You lose the graphical interface but gain all of the functionality of writing SQL in your backend of choice. Access won't rearrange the formatting on pass-through queries.