-
You didn't let your sp to accept variable, try following:
CREATE PROCEDURE usp_sp1
@DatabaseName sysname
AS
DECLARE @cmd varchar(500)
set @cmd = 'master.dbo.xp_sqlmaint ''-S server -U user -P password -D ' + @DatabaseName + ' -PlanName Optimization ' + @DatabaseName + ' -Rpt C:\MaintPlanRpts\OptimizationFor ' + @DatabaseName + ' -DelTxtRpt 1DAYS -WriteHistory -RebldIdx 10 -RmUnusedSpace 50 10 '''
exec (@cmd)
-
I tried that and in query analyzer I executed it like this:
execute msdb.dbo.usp_RebuildIndexes 'DBName'
Error message:
(28 row(s) affected)
Server: Msg 22029, Level 16, State 1, Line 0
sqlmaint.exe failed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|