如何强制MS Access保留其SQL格式?

时间:2021-01-17 00:00:12

I have a lot of SQL at work in MS-Access, and I need to formatted so that it's human readable. The issue is when I change between views I end up with the ql being condensed down into something that I can't read.

我在MS-Access中有很多SQL工作,我需要格式化,以便它是人类可读的。问题是当我在视图之间进行切换时,我最终会将ql压缩成我无法阅读的内容。

How do I force SQL to retain it's 'shape' when I go to other views?

当我转到其他视图时,如何强制SQL保留它的“形状”?

1 个解决方案

#1


7  

I found a hack, here. The secret lies in enclosing your query inside a dummy query. Like so:

我在这里找到了一个黑客。秘诀在于将查询包含在虚拟查询中。像这样:

SELECT * FROM (SELECT   <-----here
Table1.Field1,
Table1.Field2
FROM
Table1

WHERE
Table1.Field2 = "Yes") AS query1 <-----here

I've indicated where and how you wrap the code. The only issue I can see is if you wanted to edit the code in design view, then it doesn't seem to pick the enclosed code up at all.

我已经指出了你在哪里以及如何包装代码。我能看到的唯一问题是如果你想在设计视图中编辑代码,那么它似乎根本不会选择所附的代码。

#1


7  

I found a hack, here. The secret lies in enclosing your query inside a dummy query. Like so:

我在这里找到了一个黑客。秘诀在于将查询包含在虚拟查询中。像这样:

SELECT * FROM (SELECT   <-----here
Table1.Field1,
Table1.Field2
FROM
Table1

WHERE
Table1.Field2 = "Yes") AS query1 <-----here

I've indicated where and how you wrap the code. The only issue I can see is if you wanted to edit the code in design view, then it doesn't seem to pick the enclosed code up at all.

我已经指出了你在哪里以及如何包装代码。我能看到的唯一问题是如果你想在设计视图中编辑代码,那么它似乎根本不会选择所附的代码。