Tips for using Access

Source: Internet
Author: User
Tags idate
The following SQL statement passed the test in Access XP Query
Table creation:
Create Table tab1 (
Id counter,
Name string,
Age integer,
[Date] datetime );
TIPS:
Use counter to declare the auto-increment field.
Fields with field names as keywords are enclosed in square brackets []. It is also feasible to use numbers as field names.

Index creation:
The following statement creates a repeatable index on the date column of tab1
Create index idate on tab1 ([date]);
After completion, the date index attribute of the access field is displayed as-Yes (repeated ).
The following statement creates a non-repeated index on the name column of tab1
Create unique index INAME on tab1 (name );
After the access is complete, the field name index attribute is displayed as-Yes (no duplicates ).
The following statement deletes the two indexes just created
Drop index idate on tab1;
Drop index INAME on tab1;

Comparison between access and SQL Server Update statements:
Update statements for updating multiple tables in sqlserver:
Update tab1
Set a. Name = B. Name
From tab1 A, tab2 B
Where a. ID = B. ID;
The SQL statement with the same function should be
Update tab1 A, tab2 B
Set a. Name = B. Name
Where a. ID = B. ID;
That is, the update statement in access does not have the from clause. All referenced tables are listed after the update keyword.
In the above example, if tab2 can be a table but a query, for example:
Update tab1 A, (select ID, name from tab2) B
Set a. Name = B. Name
Where a. ID = B. ID;

Access Multiple different access databases-use the in clause in SQL:
Select a. *, B. * From tab1 A, tab2 B in 'db2. mdb 'Where a. ID = B. ID;
The preceding SQL statement queries all the records associated with IDs in tab1 and db2.mdb (in the current folder) in the current database.
Disadvantage-the external database cannot contain a password.

Access other ODBC data sources in access
The following example shows how to query data in sqlserver in access.
Select * From tab1 in [ODBC]
[ODBC; driver = SQL Server; uid = sa; Pwd =; server = 127.0.0.1; database = demo;]
The complete parameters of the external data source connection attribute are:
[ODBC; driver = driver; server = server; database = database; uid = user; Pwd = password;]
Where driver = driver can be in the Registry
HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ odbcinst. ini \
.

Access supports subqueries

Access supports external connections, but does not include complete external connections.
Left join or right join
But not supported
Full outer join or full join

Date query in access
Note: The Date and Time delimiter in access is # Instead of quotation marks.
Select * From tab1 where [date]> #2002-1-1 #;
I used this in Delphi.
SQL. Add (format (
'Select * From tab1 where [date]> # % s #;',
[Datetostr (date)]);

The strings in access can be separated by double quotation marks, but sqlserver does not recognize them. To facilitate migration and compatibility,
We recommend that you use single quotes as the string separator.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.