简体   繁体   中英

Using SQL Server Management Studio “Script To” Feature via Code

The Microsoft SQL Server Management Studio has a feature to recreate objects by right-clicking on database objects and generating their "Create Statement" based on their meta information stored in the database.

It is possible to get "Create Statement" String from code?

I would like to connect to one database via python, get the string for creating certain indices and then executing this strings on another database, in order to create equal index structure among different databases.

You can use sp_helpindex by Kimberly Tripp as the base script and adopt it for your needs. It gets out of system tables all the information you need to generate "CREATE INDEX" statements

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM