I can’t find the right syntax to rename a table in T-SQL when the table name contains an ‘]’ character.
It seems like the sp_rename procedure doesn’t use the same escaping rules as T-SQL DDL.
How can this be done?
CREATE SCHEMA MySchema
CREATE TABLE [MySchema].[MyTab]]le5](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[SomeField] [bigint] NULL,
[MyField] [nvarchar](4000) NULL)
EXEC sp_rename 'MySchema.MyTa]ble5', 'MyTable6'
Use the same syntax as CREATE TABLE…
Or rely on SET QUOTED_IDENTIFIER ON and a different delimiter