Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > BOOK: Beginning SQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning SQL
This is the forum to discuss the Wrox book Beginning SQL by Paul Wilton, John Colby; ISBN: 9780764577321
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL 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 November 23rd, 2006, 05:33 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Rename a Field?

ALTER TABLE TEST2 RENAME NEWFIELD2 TO NEWCOLUMN

I am trying to rename a column in a query, but it fails wth the following error:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'NEWFIELD2'.

I also noted that in SQL Query Analyzer that the colour coding of the query indicates that RENAME isn't a correct command (ie: not shown in blue)

I also had the same problem when I tried to rename a whole table.

Any advice?

Regards,

Sean Anderson
__________________
Regards,

Sean Anderson
Reply With Quote
  #2 (permalink)  
Old November 23rd, 2006, 06:29 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii seananderson!!
Hope this will help you
http://p2p.wrox.com/topic.asp?TOPIC_ID=15190

Other Articles
http://msdn2.microsoft.com/en-US/library/ms188351.aspx
http://www.functionx.com/sqlserver/Lesson05b.htm
http://databases.aspfaq.com/database...-a-column.html

Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old May 20th, 2011, 06:19 AM
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by seananderson View Post
ALTER TABLE TEST2 RENAME NEWFIELD2 TO NEWCOLUMN

I am trying to rename a column in a query, but it fails wth the following error:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'NEWFIELD2'.

I also noted that in SQL Query Analyzer that the colour coding of the query indicates that RENAME isn't a correct command (ie: not shown in blue)

I also had the same problem when I tried to rename a whole table.

Any advice?

Regards,

Sean Anderson

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
Rename Field using SQL spazband Access 5 May 20th, 2011 06:20 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 06:43 AM.


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