Rename column SQL Server 2008
Use sp_rename
EXEC sp_RENAME 'TableName.OldColumnName' , 'NewColumnName', 'COLUMN'
See: SQL SERVER – How to Rename a Column Name or Table Name
Documentation: sp_rename (Transact-SQL)
For your case it would be:
EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN'
Remember to use single quotes to enclose your values.
Change column name in SQL Server 2008
You need to use the sp_rename command, or use Management Studio to do it visually - make sure you do it at a quiet period, and make sure it has been done in pre-production first with testing!
Incidentally I would keep away from A/C - the slash sign is special meaning division.
The documentation for sp_rename is here, example B is most appropriate.
http://msdn.microsoft.com/en-us/library/ms188351.aspx
how to rename column name with T-SQL
I don't really understand how your table is set up - ie. the table name, the column name etc - so this is an example of how the proc works for column renames:
If I had a table like this:
CREATE TABLE [dbo].[Company](
[ID] [int],
[CompanyName] [varchar](20)
)
and wanted to change the [CompanyName]
column, this is the command:
EXEC sys.sp_rename
@objname = N'dbo.Company.CompanyName',
@newname = 'Name',
@objtype = 'COLUMN'
I suspect that your first argument is not correct.
From the documentation (sp_rename (Transact-SQL))
If the object to be renamed is a column in a table, object_name must be in the form table.column or schema.table.column. If the object to be renamed is an index, object_name must be in the form table.index or schema.table.index
Sql server rename a column
Just a reminder. Renaming columns is dangerous, because it might break scripts.
sp_rename 'MYDB.FOO', 'BAR', 'COLUMN';
Rename Column name in sql server 2008
Matrix.Sr.No
means the No
column in the Sr
table of the Matrix
schema in the current database. Try escaping the name:
sp_RENAME 'Matrix.[Sr.No.]','ID','COLUMN';
Rename column in SQL Server
EXEC sp_rename 'Categories.Active', 'CategoriesActive', 'COLUMN'
How to Rename Column name using DDL Statement in SQL
Execute this,
sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'
How do you rename columns using a Visual Studio Database Project?
After looking into this more it seems the refactoring feature is available in the Premium and Ultimate versions of Visual Studio 2010 and not in the Professional version.
Related Topics
Sub Queries in Check Constraint
How to Update Top 100 Records in SQL Server
Execute Stored Procedure from a Function
Add Unique Constraint to Combination of Two Columns
How to Run a Stored Procedure in SQL Server Every Hour
Fastest Check If Row Exists in Postgresql
What Does the Colon Sign ":" Do in a SQL Query
Why Use a Join Clause Versus a Where Condition
SQL Server Equivalent to MySQL Enum Data Type
How to Send Email from Postgresql Trigger
How to Create a Foreign Key in SQL Server
SQL Query - Concatenating Results into One String
How to Delete from Select in MySQL
SQL Server Select Distinct Rows Using Most Recent Value Only
How Can a Left Outer Join Return More Records Than Exist in the Left Table