Bug: Data Sync Script not handling spaces in index names correctly

After performing a data compare if I generate a sync script to make the destination look like the source and choose the option to drop/re-create foreign keys and indexes, the creation script is not handling index names that contain spaces correctly (it is omitting the square brackets).

Example:

CREATE NONCLUSTERED INDEX Check Account ON [dbo].[Check Register Items]
([Check Account] ASC)
WITH (PAD_INDEX = OFF,
FILLFACTOR = 92,
IGNORE_DUP_KEY = OFF,
STATISTICS_NORECOMPUTE = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
)

Should have been

CREATE NONCLUSTERED INDEX [Check Account] ON [dbo].[Check Register Items]

Another example:

CREATE NONCLUSTERED INDEX IX_General Ledger Transaction ON [dbo].[General Ledger Transaction]
should have been:

CREATE NONCLUSTERED INDEX [IX_General Ledger Transaction] ON [dbo].[General Ledger Transaction]

Darren

Also, certain illegal keywords were also not wrapped in square brackets. For example this statement is invalid because of the reserved word “key”:

CREATE NONCLUSTERED INDEX Key ON [dbo].[Accounts Payable Voucher Footer]

this should be:

CREATE NONCLUSTERED INDEX [Key] ON [dbo].[Accounts Payable Voucher Footer]

as a quick fix in the next build might I suggest just wrapping all object names in square brackets? (Perhaps using quotename() function when generating this?)