0
I needed to rename a column from a table in Sql Server and used the stored SP_RENAME system processor.
I used it as follows:
USE [meu_db]
GO
EXEC sp_rename '[dbo].[minhaTabela].[minhaColunaAntiga]', '[minhaColunaNova]', 'COLUMN';
GO
That is, I tried to change the name from 'myColunaAntiga' to 'myColunaNova', but the way I put it, sp_rename considered the characters '[' and ']' literal and the column became called '[myColunaNova]' instead of 'myColunaNew'.
Now I’m trying to fix it like this:
EXEC sp_rename '[dbo].[minhaTabela].[minhaColunaNova]', 'minhaColunaNova', 'COLUMN';
GO
But it didn’t work.
I tried too:
EXEC sp_rename '[dbo].[minhaTabela].[[minhaColunaNova]]', 'minhaColunaNova', 'COLUMN';
GO
But it didn’t work either. I even tried with 3 '[]' and it didn’t work either.
Someone would have an idea how to fix this?
It worked, I used it like this:
EXEC sp_rename 'dbo.minhaTabela."[minhaColunaNova]"', 'minhaColunaNova', 'COLUMN';
GO
. Thank you Seal.– Marcos Tulio