How can I generate Index script from a database | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How can I generate Index script from a database

I want to generate Index script from one database, This database having around 100 tables. So I want to retrieve the only Index from this 100 tables. Could you please help me out here.
Try this select, from sysindexes ind,sysobjects obj
where = Cheers
The above will give all the indexes with respective table names for databases, probably you can refine it more to add syscolumns to get columns they apply to as well. Cheers
If you want to generate scripts of all indexes created or any object you need
to open Microsoft SQL server management Studio —> Right click on Database —> Tasks –>Generate Scripts This will open script wizard , which is freindly GUI where you select and deselect the objects of your choice. Cheers
[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />] Nice solution to make use of generate script wizard in SQL 2005, as it is ignored by users many times.<br /><br /><b>Satya SKJ</b><br />Microsoft SQL Server MVP<br />Writer, Contributing Editor & Moderator<br /<a target="_blank" href=http://www.SQL-Server-Performance.Com>http://www.SQL-Server-Performance.Com</a><br />@<a target="_blank" href=></a><br /><br /><center><font color="teal"><font size="1">This posting is provided AS IS with no rights for the sake of <i>knowledge sharing. <hr noshade size="1">Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.</i></font id="size1"></font id="teal"></center>
or you can use this free console app I wrote – it’s useful for automating script generation since you can launch it from a bat file, etc.