View Single Post
  #5 (permalink)  
Old May 20th, 2011, 07:17 AM
rfulani rfulani is offline
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default DO it

Quote:
Originally Posted by pipelineconsulting View Post
I have an Access database and wish to change the name of a table column from within an ASP.NET application.

I would prefer to use an SQL statment and an OleDbCommand to do this and then ExecuteNonQuery() etc.

Two possible SQL statements are:

Code:
ALTER TABLE tablename RENAME COLUMN OldName TO NewName
or
Code:
ALTER TABLE tablename RENAME OldName TO NewName
Neither of these statements work and I get an SQL Syntax Error.

Does anyone know what the correct SQL statment is? I can add and remove columns OK using similar SQL statements, just can't rename a column/field!

Cheers

Graham Wilson


to rename

for eg chenge column name for fnmae to fname in table employee

step 1 rename employee to employe
step 2 create table employee (fname,lname , and other columns of table) as select * from employe.

then drop employe
and add constraints againn to employee if any exist.

alter table do not change name of column , table and size of column if table data exist
Reply With Quote
The Following User Says Thank You to rfulani For This Useful Post:
anvienhponline (August 11th, 2014)