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
2009-07-22 13:43:09
why do i need to use a stored procedure? isn't there a straight one line of code to do this?
2009-07-22 23:07:47
no. that's the way to do it. it's still one straight line of code :)
Mladen Prajdic
2009-07-22 23:49:33
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
2010-03-24 17:04:35