473,396 Members | 1,766 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.

SQL (ALTER TABLE doesn't work)

I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter
Nov 13 '05 #1
4 4570
@ndy wrote:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Try using an import spec and skip some columns. Altertatively leave the
column alone and use a query that doesn't include it if it's presence
upsets you that much. :-)
--
This sig left intentionally blank
Nov 13 '05 #2
@ndy wrote:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Sub DropColumn(cTable As String, cColumn As String)
Dim td As TableDef
Dim db As Database
Set db = CurrentDb
Set td = db.TableDefs(cTable)
td.Fields.Delete cColumn
Set td = Nothing
Set db = Nothing
End Sub

that works. It doesn't test, you should enter correct values!

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3
"@ndy" <an*******@hotmail.com> wrote in message
news:6c**************************@posting.google.c om...
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


What is the error message? Are you using the column in an index or primary
key constraint?
Nov 13 '05 #4
On Dec 03 2004, 03:09 am, an*******@hotmail.com (@ndy) wrote in
news:6c**************************@posting.google.c om:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Because the column name contains a minus sign, it has to be enclosed in
square brackets:

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN [Dossier-beheerder]"

--
remove a 9 to reply by email
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dylan Nicholson | last post by:
Seems that Oracle 9.2 (using MS ODBC driver) requires extra parentheses when adding multiple columns to a table: ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)) vs ...
1
by: Lannsjo | last post by:
I need to change my primary key column type from smallint to int. I have tried: ALTER TABLE livegroup MODIFY id INT UNSIGNED NOT NULL AUTO_INCREMENT; But get an error message certainly since my...
6
by: Brian Basquille | last post by:
Just started learning SQL recently. But one thing i'm still not clear on is about altering relationships between tables after they've been created. Instead of creating a foreign key when the...
7
by: Jon Combe | last post by:
I have created the following test SQL code to illustrate a real problem I have with some SQL code. CREATE TABLE JCTable ( CustomerName varchar(50) ) ALTER TABLE JCTable ADD CustomerNo int...
1
by: Euler Almeida via SQLMonster.com | last post by:
Hi people, I?m trying to alter a integer field to a decimal(12,4) field in MSACCESS 2K. Example: table : item_nota_fiscal_forn_setor_publico field : qtd_mercadoria integer NOT NULL...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
1
by: vasilip | last post by:
I'm testing out db2 for a project I'm starting that requires proper xml support and I can't seem to get both xml and spatial data to work well in the same table. Once having created a table...
3
by: Gregor KovaĨ | last post by:
Hi! I have a table with a column of BIGINT and I want to change the type to SMALLINT. Command ALTER TABLE TABLE1 ALTER COLUMN COL1 SET DATA TYPE SMALLINT does not work since I cannot specify...
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.