473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Create Table

I wants to create a table in Ms Access By using SQL statment.
Please tell me how can I do this?
And then after creating I wants to add a column in it by using SQL.
Jun 12 '07 #1
5 8421
NeoPa
32,556 Expert Mod 16PB
Search in help under CREATE TABLE statement and ALTER TABLE statement.
Jun 12 '07 #2
Search in help under CREATE TABLE statement and ALTER TABLE statement.

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE TABLE employee
  3.  
  4. (id  COUNTER PRIMARY KEY,
  5. name VARCHAR(30),
  6. address1 VARCHAR(40),
  7. address2 VARCHAR(40),
  8. Town VARCHAR(30),
  9. postcode VARCHAR(10),
  10. phone INTEGER
  11.  
  12. )
  13.  
  14.  
Try this

gareth
Jun 13 '07 #3
Where do you write SQL code?
Jun 16 '07 #4
Where do you write SQL code?
As you seem (like me ) very new to SQL then the easiest way to start this off is:

1 - open the access DB you are workig on
2 - click in to the QUERY OBJECT
3 - DOUBLE click on Create Query In Design View
4 - Close the SHOW TABLE Box that appears
5 - In VIEW change to SQL or if SQL appears in the top left Menu bar click that (depends on Access version you are using)

6 - You will be presented with SQL View and should have "SELECT;" already in place
7 - remove this and add your code

8 - save the query as what ever name and run it

If you have input correctly you'll have your table there. If you click again Access will tell you you already have the desired table.

Hope that helps you start off ground up

Gareth
Jun 16 '07 #5
NeoPa
32,556 Expert Mod 16PB
Where do you write SQL code?
Another way of using SQL code (other than the very helpful point made by GarethFX), is to create or use a string in VBA and pass it to the DoCmd.RunSQL procedure :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.   Dim strSQL As String
  3.  
  4.   strSQL = "CREATE TABLE tblEmployee (" & _
  5.            "id  COUNTER PRIMARY KEY, " & _
  6.            "name VARCHAR(30), " & _
  7.            "address1 VARCHAR(40), " & _
  8.            "address2 VARCHAR(40), " & _
  9.            "Town VARCHAR(30), " & _
  10.            "postcode VARCHAR(10), " & _
  11.            "phone INTEGER)"
  12.     Call DoCmd.RunSQL(strSQL)
  13. End Sub
Jun 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Phil Powell | last post by:
create table if not exists nnet_produkt_varegruppe ( nnet_produkt_varegruppe_id int not null auto_increment, primary key(nnet_produkt_varegruppe_id), nnet_produkt_varegruppe_navn varchar(255) not...
6
by: dev | last post by:
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? please any help? if i have 10 fields in 1 record and...
4
by: Michael Jackson | last post by:
I have a stored procedure to create a table. In my program I want the user to name the table to be created, therefore I pass a parameter to the SP for the table name. I cannot get it to work. It...
7
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
1
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet,...
24
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber...
6
by: Peter Nurse | last post by:
For reasons that are not relevant (though I explain them below *), I want, for all my users whatever privelige level, an SP which creates and inserts into a temporary table and then another SP...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
2
by: lakuma | last post by:
Hi, I have a table called A (say) with columns called name, place, animal and thing. I would want to write an on insert trigger on this table, which would create a table with the name of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.