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
 General SQL Server Forums
 New to SQL Server Programming
 script all the indexes in a database

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-17 : 11:37:27
Dear All,
my database has around 110 tables, and a lot of indexes on that database are existing. is it possible to generate cerate index script for all indexes?
in a single sentence, i need the script to generate indexes in a database. with the script, i'd like to create the same indexes on the test environment. so please help me here

Arnav
Even you learn 1%, Learn it with 100% confidence.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-17 : 11:39:08
cant you use transfer database objects task available in ssis for this?
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-17 : 12:37:32
i'm generating a new snapshot for the replication. for that i need all the previous index script.

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-17 : 13:46:34
How to generate a script (Enterprise Manager)
To generate a script

Expand a server group, and then expand a server.


Expand Databases, right-click the database to script, point to All Tasks, and then click Generate SQL Scripts.


On the General tab, select the database objects to script. By default, all objects in the database are scripted.


On the Formatting tab, select from the script formatting options:
Generate the CREATE <object> command for each object so that each object to be scripted is explicitly created using its existing definition. This is selected by default.


Generate the DROP <object> command for each object so that a DROP statement is added to the script for each object to be scripted. This is selected by default.


Caution When executed, this causes any existing objects in the database (where the script is executed with the same name as objects listed in the script) to be deleted first.

Generate scripts for all dependent objects so that all objects in the database which are needed to create the objects listed in the script are included automatically in the script if not already selected.


Include descriptive headers in the script files so that a comment is added to the file for each object listed in the script.
On the Options tab, select the security-related, table-related, and script file-related options.


On the General tab, click Preview to view a preview of the generated script.

See Also

Documenting and Scripting Databases
Go to Top of Page
   

- Advertisement -