Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • Last Modified:

sql server 2008 query

I'm using sql server 2008 and Sql Server Management Studio.

I have some scripts to create some stored procedures.
I already know how to execute one stored procedure at time in Sql Server Management Studio.
I just copy an paste the script into SSMS and then click Execute.

I have like 100 working stored procedures, so doing one at a time this way will take a bit.

If I have 4 stored procedure scriptes called the following:

StoredProcedure1.sql
StoredProcedure2.sql
StoredProcedure3.sql
StoredProcedure4.sql

How do I execute these 4 scripts all at once using Sql Server Management Studio?
0
maqskywalker
Asked:
maqskywalker
  • 2
1 Solution
 
Angelp1ayCommented:
Switch to SSMS SQLCMD mode by clicking Query in the menu bar and selecting SQLCMD Mode.

Then execute this:
:setvar path "C:\WhateverPath\"
:r $(path)StoredProcedure1.sql
:r $(path)StoredProcedure2.sql
:r $(path)StoredProcedure3.sql
:r $(path)StoredProcedure4.sql

Open in new window

0
 
dannygonzalez09Commented:
You can create another Stored proc and embed all these in that stored proc
0
 
Angelp1ayCommented:
Enabling SQL CMD mode under the Query menuNote the grey background for SQL CMD commands
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now