how to change the column name [Resolved]

Posted by kishore_guruju-3194 under Sql Server on 2/17/2010 | Views : 1599 | Status : [Member] | Replies : 8
how to change the existed column name in sql server?




Responses

Posted by: Abhi2434 on: 2/17/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down

Resolved
Use

sp_rename 'MyTable.oldName', 'MyTable.newName', 'COLUMN' 


This will rename "oldName" with the "newName" of a column in table "MyTable"

I hope this helps you.

www.abhisheksur.com

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/18/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Kishore_guruju@yahoo.co.in Please Mark the Answer as "Resolved"

Thank you for posting at Dotnetfunda
[Administrator]

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kishore_guruju-3194 on: 2/18/2010 [Member] Starter

Up
0
Down
i tried this but it shows error..

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/18/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Show us the Error and show us the Statement you used.

Thank you for posting at Dotnetfunda
[Administrator]

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kishore_guruju-3194 on: 2/18/2010 [Member] Starter

Up
0
Down
ok thanks it works, but it shows the warning like.. Changing any part of an object name could break scripts and stored procedures.


kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/18/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
This is not a Problem , its just a warning that means if there is any other Sp or part of your application that uses the name of the Field it might not work. If you have that situation you need to go and change that part too.



Thank you for posting at Dotnetfunda
[Administrator]

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kishore_guruju-3194 on: 2/18/2010 [Member] Starter

Up
0
Down
ok thanks for your quick replies...


kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/18/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Thank you for Posting at DotnetFunda.

Please mark your answer as "Resolved" near Abhi2434 's answer

:)

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

kishore_guruju-3194, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response