Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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
Thread Tools Display Modes
  #1 (permalink)  
Old November 23rd, 2004, 09:34 AM
Authorized User
Join Date: Oct 2004
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rename a column


I need to change a column name in a table , i have used the following but it doesnt work

ALTER TABLE mytablename CHANGE oldcolumnname newcolumnname

please let me know why this doesnt work

Reply With Quote
  #2 (permalink)  
Old November 23rd, 2004, 09:46 AM
Authorized User
Join Date: Oct 2004
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

Its ok i found the command
sp_rename tablename.oldcolname,newcolname,'COLUMN'

Reply With Quote
  #3 (permalink)  
Old November 24th, 2004, 09:03 AM
bph bph is offline
Friend of Wrox
Join Date: Dec 2003
Location: , , .
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts

You could also, in EM, right click on the table, click design table, find column and make the chnage there.

But it's always better to know the sp.

Reply With Quote
  #4 (permalink)  
Old December 16th, 2004, 12:11 AM
Friend of Wrox
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel

sp_rename is the system stored procedure used to rename user created objects like "stored procedure", "trigger", "table" etc., This SP works pretty fine as long as you don't use it to rename a 'Stored Proc", "Trigger" or a "View".

For more information checkout my blog entry @ http://vadivel.thinkingms.com/PermaL...6-b255e22e47c3

Reply With Quote

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 7 September 21st, 2017 04:16 PM
how to use rename method ajeshss C# 1 February 23rd, 2012 07:14 PM
rename column name dyanmically sudhirbharti SQL Server 2000 3 February 7th, 2008 06:19 PM
copy and rename red_fiesta Classic ASP Professional 1 November 8th, 2006 10:00 AM
Rename node name venutm XML 0 March 9th, 2006 02:36 PM

All times are GMT -4. The time now is 09:52 PM.

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