Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Create sp in a batch file
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

249 Posts

Posted - 10/08/2012 :  10:30:56  Show Profile  Reply with Quote
Hi there,

I got 20 stored procedures to create. I have scripts ready. Is there any way to run them in a batch file by some commands? I mean not run them in query windows one by one manually. Thanks in advance.

Edited by - allan8964 on 10/08/2012 10:31:31

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/08/2012 :  11:33:22  Show Profile  Reply with Quote
Since you have only 20 stored procs, I would run them manually, one at time, making sure that there are no error messages as you create each stored proc.

If you do want to run them all together, if the scripts are in one file, you can separate the creation script for each with a batch separator (GO) and then run them all at once.
create procedure dbo.Proc1
create procedure dbo.Proc2

If the scripts are in separate files, you can create a command file that calls the SQLCMD utility to execute each file. You can also do a similar thing using a powershell script and SQLCMD or Invoke-SqlCmd.

But, to reiterate what I initially said: I would take 20 minutes and run them one at a time because it is easier to catch any errors/warnings when you are creating the stored procedures rather than trying to debug later.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000