Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Existing Stored Procedures In SQL Server

I restored my development database from production, and the stored procedures I need in my development environment doesn't exist in my production database. Is there a command Ii can use to import the developmetn stored procedures back into SQL Server. There are about 88 files, as each procedure is in a different text file.

TIA! Chris

like image 447
Chris Avatar asked Dec 18 '08 17:12

Chris


Video Answer


2 Answers

Oops, you did the painful way of generating scripts. You should have created a single script for all procedures by right clicking on the database in SSMS, choosing Tasks -> Generate Scripts.

However, if you don't want to go through that process again, open up a cmd shell in the folder and remember those old batch file days:

for %f in (*.sql) do sqlcmd -i %f

This should do the trick! You could add other parameters to sqlcmd if required (i.e. login, password, server name, ...). To see a list of switches just do a sqlcmd -h.

like image 199
mmx Avatar answered Nov 14 '22 23:11

mmx


For SQL 2K & 2K5, you want this tool.

I asked a similar question awhile ago and got this advice from Mike L (give him votes here).

like image 27
Austin Salonen Avatar answered Nov 15 '22 01:11

Austin Salonen