I need to write some code for renaming a column in SQL Server 2008.
When scripting that in Management Studio I got a double renaming :
NAME1 ==> TEMPNAME ==> NAME2
BEGIN TRANSACTION
GO
EXECUTE sp_rename N'dbo.Table_1.columFirstName', N'Tmp_columSecondName_2', 'COLUMN'
GO
EXECUTE sp_rename N'dbo.Table_1.Tmp_columSecondName_2', N'columSecondName', 'COLUMN'
GO
ALTER TABLE dbo.Table_1 SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
But when I do it in one go, It works just fine.
Why the column first is renamed to a temporary name? Does it makes sense when coding a renaming algoritm to do the same?
Thanks!