Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 20th, 2004, 01:36 PM
Registered User
 
Join Date: Sep 2003
Location: Escondido, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to spazband Send a message via Yahoo to spazband
Default Rename Field using SQL

I am in the process of writing a utility that will allow for database modifications via SQL. One of the issues I am up against is how to rename a field inside of a table using SQL. This needs to be done because I have to set an index on a field named 'Year' and since this is a key word with Access, the sql statement is giving me fits. I have to rename the field, set the index then rename it back. Everything is done except for the renaming of the field.
Reply With Quote
  #2 (permalink)  
Old February 20th, 2004, 01:46 PM
joefawcett's Avatar
Wrox Author
Points: 9,712, Level: 42
Points: 9,712, Level: 42 Points: 9,712, Level: 42 Points: 9,712, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,066
Thanks: 1
Thanked 36 Times in 35 Posts
Default

As an aside you can wrap all names in brackets and they will not be treated as keywords:
Code:
SELECT [Year], [Date] FROM tblCalendar...
--

Joe
Reply With Quote
  #3 (permalink)  
Old February 20th, 2004, 02:17 PM
Registered User
 
Join Date: Sep 2003
Location: Escondido, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to spazband Send a message via Yahoo to spazband
Default

That I have done and it will work in Access directly - however it will not sure when running the same query using ADO though a VB front end.
Reply With Quote
  #4 (permalink)  
Old February 20th, 2004, 02:21 PM
Registered User
 
Join Date: Sep 2003
Location: Escondido, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to spazband Send a message via Yahoo to spazband
Default

more importantly - I am looking for the proper format of a query that can be used to rename the field of a table. I believe it will be an 'Alter' or 'Update' query. Either way, I am sure that a 'Select' query will not do much for me.
Reply With Quote
  #5 (permalink)  
Old May 20th, 2011, 06:20 AM
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by spazband View Post
I am in the process of writing a utility that will allow for database modifications via SQL. One of the issues I am up against is how to rename a field inside of a table using SQL. This needs to be done because I have to set an index on a field named 'Year' and since this is a key word with Access, the sql statement is giving me fits. I have to rename the field, set the index then rename it back. Everything is done except for the renaming of the field.
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
  #6 (permalink)  
Old May 20th, 2011, 06:20 AM
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default do

Quote:
Originally Posted by spazband View Post
I am in the process of writing a utility that will allow for database modifications via SQL. One of the issues I am up against is how to rename a field inside of a table using SQL. This needs to be done because I have to set an index on a field named 'Year' and since this is a key word with Access, the sql statement is giving me fits. I have to rename the field, set the index then rename it back. Everything is done except for the renaming of the field.
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
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename a Column using SQL pipelineconsulting Classic ASP Databases 5 September 16th, 2013 10:11 AM
SQL Rename a Field? seananderson BOOK: Beginning SQL 2 May 20th, 2011 06:19 AM
Rename a table through SQL in SQL Server pankaj_daga SQL Server 2000 5 June 27th, 2008 03:31 AM
How to rename a table in SQL Server leo_vinay Classic ASP Databases 1 January 4th, 2005 11:48 PM
sql expression field zouky Crystal Reports 0 October 29th, 2004 02:18 AM



All times are GMT -4. The time now is 05:49 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.