Re: Buggy SQL Syntax for External File Path in Access 2007



On 6 Mar 2009 23:55:33 GMT, "David W. Fenton"
<XXXusenet@xxxxxxxxxxxxxxxxxxx> wrote:

<snip>

Hoping someone at least has an explanation,

[]. AS Alias is Jet SQL's syntax for derived tables. Standard ANSI
syntax is () As Alias, and when you type that in, you find that
Access converts it to Jet's syntax.

This is a good thing, seems to me.

And I've used it for years (I do lots of SQL with derived tables,
though mostly not in saved queries).

One option you might consider is setting your database to use ANSI
92 SQL, which will mean that you can use the standard () AS Alias
syntax. But it also means you have to use ANSI wildcards, % in place
of * and _ in place of ?.

Now, as to your other assertion, that the SQL breaks if you edit it,
I've never had that issue myself. Perhaps your edit is in error?
It's certainly the case that the bracket syntax means you can't have
any brackets inside the SELECT statement of your derived table, so
if you're introducing the need for brackets (e.g., by adding a field
to the SELECT clause that has a space or non-standard character in
its name), then that would definitely break it. If you've got
fields/tables with badly-designed names (i.e., with spaces and
non-alphanumeric characters) then you're going to have to use
brackets and in that case, ANSI 92 mode is probably going to make
life easier for working with derived tables (though it means
converting all the wildcards...).

But the better alternative is to NOT USE STUPID NAMES for fields and
tables. That means no spaces and no funny characters.

Of course, often you have no control over the schema so you're
forced to use badly-named fields/tables. In that case, I'd likely
create saved queries that alias the fields to good names, or if
using SQL Server, create a server-side view with the aliases and use
that in place of the basic table. That way, you don't have to worry
about mucking around with ANSI 92 mode and finessing issues with
brackets in SQL derived tables.

Thanks for that. (Been on vacation, sorry for delay)

I didn't know that about derived tables. I should probably delve a
little deeper into Jet.

I've thought about using ANSI 92, just haven't moved forward with it.
I rarely use wildcards, if I can help it.

Lol about the STUPID NAMES. I use perfectly good names in the
databases I design. Unfortunately, most of the databases I support
were created by a complete idiot (and she was well paid). I've
considered posting some of what I find on the Daily WTF but there are
too many snobs there that would reply, "TRWTF is Access!"

I often use intermediate queries to rename fields into someting sane.

Anyway, thanks.

RD

.



Relevant Pages

  • Re: Buggy SQL Syntax for External File Path in Access 2007
    ... Parentheses around the sub-select are turned into square brackets ... AS Alias is Jet SQL's syntax for derived tables. ... One option you might consider is setting your database to use ANSI ... 92 SQL, which will mean that you can use the standard AS Alias ...
    (microsoft.public.access.modulesdaovba)
  • Re: 9i: Check- constraint Upper(Column)
    ... the brackets are *not* optional. ... So it sounds to me as *alias* is a nice word for a bug. ... the table is referenced in the index definition (but I have ... An error 'missing brackets' is not appropriate here, for the syntax is ...
    (comp.databases.oracle.misc)
  • Re: Trigger to timestamp all Updates, tables with Multiple field Primary Key
    ... Hugo was talking about the syntax of the UPDATE involving a join, ... Using a JOIN in an update in not ANSI standard; ANSI requires subqueries to get the same result. ... ON clause or a WHERE clause is not the issue here. ...
    (microsoft.public.sqlserver.server)
  • Re: Identischer SQL - Befehl liefert zwei unterschiedliche Werte
    ... portabel ist ausschliesslich die ANSI Syntax. ... Joe Celko's SQL for Smarties. ... Und das ANSI JOIN gehört zum SQL 92 Standard, ...
    (microsoft.public.de.sqlserver)
  • Re: Stored Procedure Enter Same Record Twice?
    ... >> I'm kind of new to sql server 2000. ... >> join syntax to the ANSI style. ... > You can wait on the ANSI conversion. ... > first using the old style syntax. ...
    (microsoft.public.sqlserver.programming)

Quantcast