Solved

sql server 2008 query

Posted on 2013-12-11
3
512 Views
Last Modified: 2013-12-11
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
Comment
Question by:maqskywalker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Angelp1ay
ID: 39712775
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
 
LVL 5

Expert Comment

by:dannygonzalez09
ID: 39712781
You can create another Stored proc and embed all these in that stored proc
0
 
LVL 11

Accepted Solution

by:
Angelp1ay earned 500 total points
ID: 39712792
Enabling SQL CMD mode under the Query menuNote the grey background for SQL CMD commands
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question