In SQL Server Management Studio, I have a database with 200 stored procedures. I'm exporting each stored procedure as a script, by right clicking -> script stored procedure -> CREATE To -> File.
Is it possible to export all procedures at once, using a powershell script or anything else?
3条答案
按热度按时间xqk2d5yq1#
Use the Generate Scripts tool in SSMS:
6ljaweal2#
If you are using MGT for MSSQL, then you follow these steps.
DONE.
There are advance options at step 7. to create each procs with drop and create option or just create options. go through those if you need.
tc.
8qgya5xd3#
I have developed a C# application that can accomplish this, scripting out all tables, views, stored procedures, functions, etc. to text files (one per object). This is very useful for scripting out the objects on a regular basis then keeping track of them in a Git repository. Download the DB Schema Export Tool from https://github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool/releases
Example command line for automation:
On Linux, use
mono DB_Schema_Export_Tool.exe
There are other command line switches available; see the Readme . In addition to SQL Server, the software supports Postgres. Example output files can be found at https://github.com/PNNL-Comp-Mass-Spec/DBSchema_DMS/tree/master/DMS_Pipeline