Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force MS Access to retain its SQL formatting?

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 SQL being condensed down into something that I can't read.

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

like image 217
AncientSwordRage Avatar asked Aug 13 '12 07:08

AncientSwordRage


People also ask

How do I change the Format of a field in access?

Access opens the table in Datasheet view. Select the field (the column) that you want to change. On the Fields tab, in the Properties group, click the arrow in the drop-down list next to Data Type, and then select a data type. Save your changes.

How do you optimize an Access query?

To make queries run faster, you should have indexes on all fields in the query that join, restrict, or sort the data. Whenever possible, link on Primary Key fields instead of other fields. Indexes are most critical on tables with large numbers of records, so you may not see a difference on small tables.


1 Answers

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.

like image 150
AncientSwordRage Avatar answered Oct 07 '22 17:10

AncientSwordRage