tags:

views:

40

answers:

2

Is there a way to change a column name in sql without having to recreate the table? I've tried alter table dbo.Conforming rename column [xxx] to [xxx] and it doesn't work. any other ideas?

+1  A: 

use sp_rename:

USE AdventureWorks;
GO
EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN';
GO
Mladen Prajdic
why do i need to use a stored procedure? isn't there a straight one line of code to do this?
no. that's the way to do it. it's still one straight line of code :)
Mladen Prajdic
A: 

Here is a post with explanation and nice example. There is no way to change in one line sql. We should use the SPROC. http://praveenbattula.blogspot.com/2009/05/how-to-changes-column-size-and-column.html

Rare Solutions