How do you change column names in SQL Server ?

Questions by vsateeshk   answers by vsateeshk

Showing Answers 1 - 21 of 21 Answers

Hiral

  • Feb 9th, 2007
 

Using Query Analyzer you can see the structure of the table by followin commandUse NorthWindGosp_columns [Categories]GoIn order to change the name of any column use the following commandsp_rename 'TableName.ColumnName', 'NewColumnName', 'COLUMN'Giving example for the Categories table sp_rename 'Categories.Description', 'Description1', 'COLUMN'

sarala Naidu

  • Mar 14th, 2007
 

Using the Query Analyzer may not be the right way always, you can use the SQL syntax as given below, if you are unable to have access to use the query analyzer

For Oracle 9i, the syntax is :

ALTER TABLE table_name
 RENAME COLUMN old_name to new_name;


For Microsoft SQL the syntax is :
EXEC sp_rename 'Table.[OldColumnName]', NewColumnName, 'COLUMN'

[Note here the alst terms 'COLUMN' is a must.

Deepak Bhandari

  • Mar 30th, 2007
 

Remaining the column Name:exec sp_rename ' tablename.oldcolumnname ' , ' newcolumnname ' , ' COLUMN '

Sohaib Khan

  • Apr 19th, 2007
 

select column1 as Name;

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions