Solved

sql server 2008 query

Posted on 2013-12-11
3
505 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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now