Solved

How to save an execute as a stored procedure so I can just run it

Posted on 2015-02-19
2
76 Views
Last Modified: 2015-02-19
Hi:

I have a stored procedure that takes a number of parameters.  Rather than select the parameters each time, I'd just like to run it  - e.g. RunDefrag.

I tried to save as a stored procedure but go a grammar error.  

CREATE PROCEDURE [RunDefrag]
        EXECUTE dbo.dba_indexDefrag_sp
              @executeSQL           = 1
            , @printCommands        = 1
            , @debugMode            = 1
            , @printFragmentation   = 1
            , @forceRescan          = 1
            , @maxDopRestriction    = 1
            , @minPageCount         = 8
            , @maxPageCount         = NULL
            , @minFragmentation     = 1
            , @rebuildThreshold     = 30
            , @defragDelay          = '00:00:05'
            , @defragOrderColumn    = 'page_count'
            , @defragSortOrder      = 'DESC'
            , @excludeMaxPartition  = 1
            , @timeLimit            = NULL
            , @database             = 'testDB';

Any help in figuring how to do this would be greatly appreciated.

RBS
0
Comment
Question by:RBS
2 Comments
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 40619640
hmm, just correct it:

CREATE PROCEDURE [RunDefrag] 
AS
 // your sprocs body.

Open in new window

0
 

Author Closing Comment

by:RBS
ID: 40619661
Duh - thanks (blush)

RBS
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

785 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