SQL Code in Access

D

DS

Hi there,
I have a question for someone who knows Access and SQL. Is it possible to
write SQL code and make it work in Access? I have the ability to write SQL
but I do not seem to be able to make it work in Access. Any Suggestions?
 
J

Jeff Boyce

DS

Two places to use your SQL code:

One is to create a new (empty) query and set it to SQL display mode -- copy
your SQL statement there and try to run it. Note that Access "flavor" of
SQL may vary from what you're using.

The other is to create a procedure and use your SQL statement as a SQL
string you execute in the code.

Good luck!

Jeff Boyce
<Access MVP>
 
B

Brendan Reynolds

Yes. You can use a SQL statement as the source of a DAO or ADO recordset,
the SQL property of a DAO QueryDef, the CommandText property of an ADO
Command object, or you can execute a SQL statement using the Execute method
of the DAO CurrentDb or ADO Connection objects. These are just some examples
that come readily to mind, this is not necessarily an exhaustive list.
 
M

Mike Labosh

I have a question for someone who knows Access and SQL. Is it possible to
write SQL code and make it work in Access? I have the ability to write SQL
but I do not seem to be able to make it work in Access. Any Suggestions?

People that learn SQL elsewhere frequently find a challenge in using Access.
Access has a very strange dialect of SQL:

Access likes double quotes instead of single quotes.
Access uses * instead of % with the LIKE operator
I don't think Access supports the CASE WHEN...THEN...END construct
etc.

And I don't think these subtle language differences are well documented in
the help files. You might try Googling for something like "Access ANSI
Compliance"
--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
 
R

Rick Gittins

If you want to write straight SQL code in Access you need to create a new
query then go to the menu under Query => SQL Specific => Pass-Through.
After you do this you will be able to write SQL statements in NON Access
SQL, but T-SQL and they will run without a problem.

Let me know if you need any more help with this.

Rick
 
Top