0

We have dozens of tables that are built programmatically and sometimes they need to be rebuilt. We use these tables as searchindex tables. Rebuilding the tables is done by dropping the current tables programmatically and rebuilding and filling them from scratch.

However, we would like to preserve all indexes that are added to the tables. Those indexes are added by MsAzure in auto pilot mode. Does anyone know C# code or a SQL query that will return a script that can be run afterwards to rebuilt the previous indexes. I know you can generate those scripts in SSMS but we want to do it programmatically because the amount of tables...

Peter de Bruijn
  • 792
  • 6
  • 22
  • 1
    I think you'll find what you're looking for [here](https://gallery.technet.microsoft.com/scriptcenter/SQL-Server-Generate-Index-fa790441). – Federico González May 03 '16 at 21:20
  • Instead of dropping all the indexes and the tables just to rebuild them could you instead simply truncate those tables? – Sean Lange May 03 '16 at 21:22
  • The first link and/or this link is what you need https://www.mssqltips.com/sqlservertip/3441/script-out-all-sql-server-indexes-in-a-database-using-tsql/ – BICube May 03 '16 at 22:20
  • I can't truncate them. The table structure can be changed as well... – Peter de Bruijn May 04 '16 at 12:08

0 Answers0