I entered the wrong column name and included [] as shown above [avail_memory_mb], I want to remove [] using the syntax, how do I do that?
I have tried using syntax EXEC sp_RENAME '[db_isdv_itsm].[dbo].[tbl_m_comp_sysboot_time].[avail_memory_mb]', 'avail_memory', 'COLUMN'
but an error appears
Msg 15248, Level 11, State 1, Procedure sp_RENAME, Line 247 Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
1条答案
按热度按时间bqf10yzr1#
The simplest method, in this case, would be to use a different delimit identifier to brackets (
[]
) for your column's name:If you "must" use brackets, then you need to escape the right bracket (
]
):db<>fiddle
Note that I also removed the database name in both examples. This is because
sys.sp_rename
doesn't support 4 part naming. Connect to the database first, and then use the system procedure.If you ever need to know what an object's literal should be, you can use
QUOTENAME
to find it out as well. For example:Which brings back the
nvarchar(258)
value[[avail_memory_mb]]]
. So, if you really wanted, you could do something like: