I have a question,How to Rename a column name without using a Stored Procedure in SQL SERVER-2008-R2..Can you explian briefly..
advance Thank you guys....!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 12:41 AM EDT
EXEC sp_rename is the only way I know of.
selva kumarRank #2,987 · 483 reputationPosted Oct 11, 2013, 12:48 AM EDT
http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/
http://sqlandme.com/2013/03/04/sql-server-how-to-rename-tablecolumn-in-sql-server/
Murali ReddyRank #8,218 · 226 reputationPosted Oct 11, 2013, 1:25 AM EDT
But one way to do so is create a new column with same datatype of old column and then insert all the data from old column to new column.
Then drop the Old Column.
Posted Oct 11, 2013, 1:33 AM EDT
SqlConnection sql=new SqlConnection ("Connstringstring);
SqlCommand cmd=new SqlCommand();
cmd.CommandText="ALTER TABLE table_name RENAME COLUMN old_name to new_name"
cmd.CommandType=CommandType.Text;
cmd.Connection=sql;
cmd.ExcuteCommand();
if this code helps your please mark as answer
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 1:57 AM EDT
ALTER TABLE ... RENAME COLUMN works in Oracle but not in SQL Server 2008 R2.
Check this link for what can be done using ALTER TABLE within the latter:
http://technet.microsoft.com/en-us/library/ms190273(v=sql.105).aspx
Kiran Kumar TalikotiRank #814 · 2.8K reputationPosted Oct 11, 2013, 9:34 PM EDT
Alter Table Table_Name OldColumn to New Columns //This query works only in Oracle
But
sp_rename is the only option SQL Server i think..
sudeep s kanakagiri47 reputationPosted Oct 15, 2013, 10:26 PM EDT
Pavan RamamurthyRank #1,682 · 906 reputationPosted May 8, 2023, 5:55 AM EDT
NO.
Renaming column is not possible