Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-28-2006, 10:01 PM   #1 (permalink)
 
Ultra Techie

Join Date: Feb 2006

Posts: 535

leonardmp92 is on a distinguished road

Default JET SQL question

Hello,

Using Access 2003. I have an existing table and am trying to rename a column to a new name. I know I have to use the ALTER TABLE statement, but then I am not sure how to rename the column. All the references I have show difference "dialects" to rename.

Wondering if anybody can help.

Thank you.

Mike
leonardmp92 is offline  
Old 03-29-2006, 12:06 AM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default

in access, open the table in design mode, change the column name, and save
office politics is offline  
Old 03-29-2006, 12:08 AM   #3 (permalink)
 
Ultra Techie

Join Date: Feb 2006

Posts: 535

leonardmp92 is on a distinguished road

Default

csamuels...but I want to do it by SQL VIEW, so I need the SQL code.
__________________
-Intel Celeron D 335 Prescott 533MHz FSB Socket 478
-ASUS P4P800SE ATX Intel
-Western Digital Caviar RE WD2500YD 250GB 7200 RPM 16MB Cache Serial ATA150
-CORSAIR ValueSelect 1GB (2 x 512MB) 184-Pin DDR SDRAM
-SAPPHIRE 1024-TC13-05-SAL Radeon 9250 256MB 128-bit DDR AGP 4X/8X
leonardmp92 is offline  
Old 03-29-2006, 12:11 AM   #4 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default

bah fine be difficult

http://www.blueclaw-db.com/alter_table_ddl.htm

Below is the syntax for the alter table statement borrowed from Microsoft Access 2003 help system.

ALTER TABLE table {ADD {COLUMN field type[(size)] [NOT NULL] [CONSTRAINT index] |
ALTER COLUMN field type[(size)] |
CONSTRAINT multifieldindex} |
DROP {COLUMN field I CONSTRAINT indexname} }

ex. ALTER TABLE Employees ALTER COLUMN Emp_Email TEXT(50);
office politics is offline  
Old 03-29-2006, 12:19 AM   #5 (permalink)
 
Ultra Techie

Join Date: Feb 2006

Posts: 535

leonardmp92 is on a distinguished road

Default

Thanks csamuels, great website, but this only provides commands to alter columns by adding, dropping, or changing the field type...not renaming the existing columns. I have searched many websites on the net as well as 3 SQL books I have here on my desk. I cant figure it out.
__________________
-Intel Celeron D 335 Prescott 533MHz FSB Socket 478
-ASUS P4P800SE ATX Intel
-Western Digital Caviar RE WD2500YD 250GB 7200 RPM 16MB Cache Serial ATA150
-CORSAIR ValueSelect 1GB (2 x 512MB) 184-Pin DDR SDRAM
-SAPPHIRE 1024-TC13-05-SAL Radeon 9250 256MB 128-bit DDR AGP 4X/8X
leonardmp92 is offline  
Old 03-29-2006, 12:24 AM   #6 (permalink)
 
Ultra Techie

Join Date: Feb 2006

Posts: 535

leonardmp92 is on a distinguished road

Default

This is what I got below, but I am getting an error: "Syntax error in ALTER TABLE" statement.

ALTER TABLE PURPLE
ALTER COLUMN "COLUMN1" to "COLUMN2", CHAR(15);

Also, after the error statement window is closed, does the part left highlighted show the "location" of the error?
__________________
-Intel Celeron D 335 Prescott 533MHz FSB Socket 478
-ASUS P4P800SE ATX Intel
-Western Digital Caviar RE WD2500YD 250GB 7200 RPM 16MB Cache Serial ATA150
-CORSAIR ValueSelect 1GB (2 x 512MB) 184-Pin DDR SDRAM
-SAPPHIRE 1024-TC13-05-SAL Radeon 9250 256MB 128-bit DDR AGP 4X/8X
leonardmp92 is offline  
Old 03-29-2006, 10:36 AM   #7 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default

looks like you'll have to drop the column and recreate then readd your data

Quote:
The DDL Alter Table statement provides you with the ability to ADD/DROP table fields and to change data types as well as modify or create indexes.
SQL has a stored procedure called sp_rename but i dont think this will work for an access db
office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On