Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2004, 10:34 AM
Authorized User
 
Join Date: Oct 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rename a column

Hi

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



 
Old November 23rd, 2004, 10:46 AM
Authorized User
 
Join Date: Oct 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 24th, 2004, 10:03 AM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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.

 
Old December 16th, 2004, 01:11 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

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

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





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 08:14 PM
rename column name dyanmically sudhirbharti SQL Server 2000 3 February 7th, 2008 07:19 PM
copy and rename red_fiesta Classic ASP Professional 1 November 8th, 2006 11:00 AM
Rename node name venutm XML 0 March 9th, 2006 03:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.