In SSMS, we can right click a database/table/index/… and select the "Script As" option to generate a drop and create script.
Is there a way to automate this script generation and drop the scripts to a temp location, rather than manually right clicking each object and generating them?
Best Answer
SQL Server Management Objects SMO is your answer. You can use it to accomplish this task. Here is an example to generate Create Table Scripts.