SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

allan8964
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

sunitabeck
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
as
...
GO
create procedure dbo.Proc2
as
...
GO


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  
 New 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.05 seconds. Powered By: Snitz Forums 2000