• First, see the notes above about Ola Hallengren's work. Second, you could also use the QUOTENAME function like this:

    select QUOTENAME(name) from sys.indexes;

    Another thing to keep in mind is that if you fire an index REBUILD, the index isn't available while the rebuild is running. If you're using Enterprise Edition, you can specify that you want it kept online by using the ONLINE option, but there are some restrictions you have to step around. See http://technet.microsoft.com/en-us/library/ms188388.aspx, which I'm sure you have already seen if you're writing this process.