Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Generate creation script for an index

Author  Topic 

okalosha
Starting Member

4 Posts

Posted - 2005-10-28 : 13:06:44
Hi -

I could not find an SQL script, which would generate index creation DDL for a specific table/index. Query Analyzer does it, but I need to do it programmatically. I am writing upgrader tool, which can alter or drop columns. Before altering columns, for example, I need to drop all indexes for that column, and then re-create them. So I need to programmatically generate and memorize full index definition before dropping it.

I do not want to reinvent the wheel and write the script querying sysindex and related system tables. Does anyone have a working script?

Thank you.

X002548
Not Just a Number

15586 Posts

Posted - 2005-10-28 : 14:30:58
quote:
Originally posted by okalosha

but I need to do it programmatically. I am writing upgrader tool, which can alter or drop columns. Before altering columns, for example, I need to drop all indexes for that column, and then re-create them. So I need to programmatically generate and memorize full index definition before dropping it.




[shudder]
What are you writing, an administrator tools, or some clinet application. This really shouldn't be done on the fly.
[/shudder]



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-28 : 14:31:55
http://mindsdoor.net/DMO/DMOScripting.html maybe?

Kristen
Go to Top of Page

okalosha
Starting Member

4 Posts

Posted - 2005-10-28 : 19:22:32
This is a client application for database upgrade. It should sniff out index definitions, drop indexes for particular tables, modify tables and re-create indexes.

quote:
http://mindsdoor.net/DMO/DMOScripting.html maybe?


Unfortunatelly, it is for tables/procs/functions only.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-29 : 00:29:56
I thought that might be a basis. There's other stuff there - like this one which will script the lot:

http://mindsdoor.net/DMO/DMOScriptAllDatabases.html

Kristen
Go to Top of Page
   

- Advertisement -