Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generate Index script
Message
De
01/01/2012 09:15:43
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
01/01/2012 08:03:56
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01531981
Message ID:
01532001
Vues:
52
>Thanks, Naomi
>Now I see it.
>That is helpful but it does one table at a time.
>I'm looking for a script that does the whole DB.

You may as well roll your own. You need a table with the indexes as they should be - i.e. taken from your source db. First, you need a list of tables - use sqltables() for that. Then, using
	=SQLExec(h, "EXEC sp_helpindex '"+Alltrim(Tablename)+"'","Indices")
for each table in turn, and appending from this cursor into that table, you get all the index definitions in it. Then you include that table into your tool, and on target system you run the same loop to get the existing indexes into a temp cursor. Then you compare your source table with this and generate the code to build indexes which are missing. Something like
cSQL = "CREATE INDEX ["+Alltrim(tagname)+"] ON "+;
	ALLTRIM(Tablename)+" ("+Alltrim(lcDexfields)+")"
You can fill these three variables from the source table.

Sorry I can't supply more details but the bare idea, proprietary code.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform