Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create multiple stored procedures from .sql files

Tags:

sql

sql-server

I have about 100 stored procedures files that I want to add to a new database that I created. Is there any way I can just drop them in a folder to import them? When I tried that, like how you would with windows explorer, it just opened them all in query windows.

I am using SQL Server Management Studio.

like image 945
user1989167 Avatar asked Feb 18 '23 19:02

user1989167


1 Answers

Right now you did not respond to the question in the comments to make your question clearer, but I have these two suggestions

Assuming you already have a database that uses these procedures:

  1. Right click the database in Management Studio and click on Task
  2. Click on Generate Scripts
  3. In the dialog that comes up, click next as you specify the right options
  4. Select the checkbox for "Stored Procedures"
  5. Select All the required stored procedures
  6. Select option to generate script to a new window or file
  7. You are done. Run you script on the other database

If you have access to Visual Studio

  1. Create a new SQL Server Database project
  2. Select the connection string of your new database
  3. Create a stored procedure folder and add all the stored procedure files from your system to it
  4. Right click the project and click Deploy/Publish

Hope you have the tables referenced in the stored procedures

like image 114
codingbiz Avatar answered Feb 21 '23 00:02

codingbiz