Here is one way of doing it:
select 'alter index [' + si.name + '] on [' + schema_name(so.schema_id) + '].[' + so.name + '] rebuild with (online = on)'
from sys.indexes si inner join sys.objects so on si.object_id = so.object_id
where si.object_id = object_id('TableName')
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/