?
Solved

SQL Add Field

Posted on 2008-10-21
4
Medium Priority
?
476 Views
Last Modified: 2012-05-05
Dear Expert,

I have a database file which hold around 10 fields. And now would like to add one more field by SQL statement. Can I do that like follow?

Create Tabe Test (Test Int);

Seems wrong, because it didnt allow me to go ahead...(I am using the Access)

Thanks.

Ricky.
0
Comment
Question by:Rickyyy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 375 total points
ID: 22770265
This code adds field c3 to table t1.

Private Sub Command19_Click()
    Dim dbs As Database
    Set dbs = CurrentDb
   
    dbs.Execute "ALTER TABLE t1 " _
        & "ADD COLUMN c3 CHAR(20);"
End Sub
0
 
LVL 30

Expert Comment

by:hnasr
ID: 22770287
If table is in a different database, use:
Set dbs = OpenDatabase("NameOfDatabase.mdb")

When you finish the code,
dbs.Close
0
 

Author Comment

by:Rickyyy
ID: 22774245
Run-time error '3293':
Syntax error in ALTER TABLE statement.
'------------------------------------------
Public Function Insert()
    Dim dbs As Database
    Set dbs = CurrentDb
   
    dbs.Execute "ALTER TABLE RawData " _
        & "ADD COLUMN Test INT(2);"
End Function
'------------------------------------------
any problem on it???
0
 

Author Closing Comment

by:Rickyyy
ID: 31508445
Finally, I am using the SQL statement to add the new column in tables.

ALTER TABLE rawdata ADD test int

But anyway, thanks again.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question