question

chandraa_1005 avatar image
chandraa_1005 asked

how to generate database objects script automatically?

Hi all, I have one deal in my job to generate scripts for all objects such as tables. views, sp's,triggers, functions and all related keys without data in database. I know manual process from sql server by go to task and click on generate scripts wizard. this is excellent wizard to get all but i have to do backup of objects script multiple times a day this is what my requirement. I have gone through different articles, during this process i know about power shell but i didn't use before. Is there any way to get this process without using power shell. Please help me. Your help would be very appreciated and save from risk. Chandra sekhar
database-objectsgenerate-script
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
Without purchasing a tool to do this, then Powershell is probably the next best option. It can make use of Server Management Objects (SMO) to script the objects. Probably the best article on this is https://www.simple-talk.com/sql/database-administration/automated-script-generation-with-powershell-and-smo/ I understand that you do not know Powershell, but this is a great opportunity to learn it, by understanding what the script is doing. If you don't want to know, then the script will just do it's job anyway!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.