Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generate Index script
Message
From
01/01/2012 09:15:43
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
01/01/2012 08:03:56
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01531981
Message ID:
01532001
Views:
51
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform