Use QUOTENAME( )… [or else!]
Lately, I seem to be reading a lot of "bracket-slapping" code:
SET @Sql = 'ALTER INDEX ['
+ @IndexName + '] ON ['
+ @DBName + '].['
+ @SchemaName + '].['
+ @ObjectName + '] REORGANIZE '
This is much easier to read (and easier to type!) than using the QUOTENAME() function:
SET @Sql = 'ALTER INDEX '
+ QUOTENAME(@IndexName) + ' ON '