How to prevent dupes

E

eadmati

I found this article: http://www.aspfaq.com/show.asp?id=2509. It has
been a while since I have used SQL, and it was Oracle at the time -
many years ago. How and where in Access does one enter the following:

CREATE TABLE blat
(
email VARCHAR(128) PRIMARY KEY
)
GO

Is it in the area for the existing database, and then in Tables,
create?

Thanks very much

Eric
 
A

Allen Browne

Interface
======
To create this table in Access, you would normally use the interface:
1. Select the Table tab of the Database window.
2. Click New.
3. Type your field name email, and choose the Data type Text.
4. Click the Key icon on the toolbar to make it the primary key.
5. Save the table with the name blat.

SQL
===
If you wanted to execute a DDL query, you could:
1. Select the Query tab of the Database window.
2. Click New, and close the dialogs Access offers.
3. Switch the query to SQL View (View menu).
4. Type in your SQL statement.
5. Execute it by clicking Run on the Toolbar.
I'm not sure it will recognise VARCHAR in this context.
JET normally expects TEXT.
For a comparison of the various names for fields, see:
http://allenbrowne.com/ser-49.html

Code
====
If you wanted to do this in a code context, you could:
1. Press Ctrl+G to open the Immediate window
2. Enter this (one line):
dbEngine(0)(0).Execute "CREATE TABLE blat (email TEXT(128) PRIMARY
KEY)", dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top