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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 11, 2013, 4:41 AM
EXEC sp_rename is the only way I know of.
Pavan RamamurthyPosted May 8, 2023, 9:55 AM
NO.
Renaming column is not possible
sudeep s kanakagiriPosted Oct 16, 2013, 2:26 AM
Kiran Kumar TalikotiPosted Oct 12, 2013, 1:34 AM
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..
VulpesPosted Oct 11, 2013, 5:57 AM
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
Posted Oct 11, 2013, 5:33 AM
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
Murali ReddyPosted Oct 11, 2013, 5:25 AM
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.
selva kumarPosted Oct 11, 2013, 4:48 AM
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/