Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL JOBS Not Functioning


SQL JOBS Not Functioning

Author
Message
OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)

Group: General Forum Members
Points: 300 Visits: 690
Cool John, Thanks Man ;-)
I will do it today itself & will let you know tomorrow..

Just one question..

IF i set the SP pne after other then..
The sequence of execution will be one after other???

I mean 1st sp excutes & then after it finishes themn only second Sp will execute???

************************************
Every Dog has a Tail !!!!! :-D
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7444 Visits: 15128
That's right, yes. You might want to test what happens if one command fails - does it abort the whole batch or does it move on to the next command. If it moves on and that isn't what you want, then you'll either need to include some error handling, or split your job into 20 separate steps.

John
OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)

Group: General Forum Members
Points: 300 Visits: 690
20 seperate steps is okas of now...
But in another Server there are almost more than 100 Db's w00t

Anyways will test it step by step, incase i have any issues, will write here.. thanks John :-)

************************************
Every Dog has a Tail !!!!! :-D
shellbus
shellbus
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 79
Could create a maintenance plan for the steps and just add them in one at a time with a success constraint. Pretty much the same thing as doing it in a job, however there's the handy little success constraint that you can add to ensure the next step doesn't execute until the previous one is successful.
OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)

Group: General Forum Members
Points: 300 Visits: 690
Hi Shell,

Acccording to John, i have followed the below step

(1) Modify the code I posted so that it fits your environment
(2) Create a new job
(3) Copy and paste the code into the "Command" field
(4) Schedule the job to run with the desired frequency and at the desired times

Now how will i confirm myself that the 2nd sp gets executed only after 1st one finishes and so on??
U have any idea

************************************
Every Dog has a Tail !!!!! :-D
shellbus
shellbus
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 79
Have you made one step for each database that the SP needs to run over?

If so:
On the job step properties, click advanced. You will then see "On success action" and make sure "go to the next step" is chosen. (You have to do this for each and every step untill the last one)

So, when Step1 completes, Step2 will run, when it completes Step3 will run and so on.

If not and your using just 1 job step to do it in a "batch" like so:
EXEC DB1.dbo.MySP 
EXEC DB2.dbo.MySP
EXEC DB3.dbo.MySP
EXEC DB4.dbo.MySP
EXEC DB5.dbo.MySP
EXEC DB6.dbo.MySP


, then as John said your going to need to do some error handling and such.

Do you need to ensure that the previous step is successful before the next one runs, or can the next step run even the first one fails?
anthony.green
anthony.green
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6091 Visits: 6077
Another way would be to use the following code


DECLARE @SQL NVARCHAR(MAX)

SELECT @SQL =
REPLACE(
CAST(
(
SELECT 'USE ' + QUOTENAME(name) +';' + CHAR(13) + CHAR(10) +
'EXECUTE schema.procedure;'+CHAR(13)+CHAR(10)
FROM sys.databases WHERE name NOT IN ('master','msdb','model','tempdb')
FOR XML PATH('')
) AS NVARCHAR(MAX)
),
'& # x 0 D ;',CHAR(13) + CHAR(10)
)
--SELECT @SQL
EXECUTE sp_executesql @SQL



just remove the spaces between '& # x 0 D ;'



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)

Group: General Forum Members
Points: 300 Visits: 690
thanks Shell.. will try to implement it

Anthony - Do u want me to paste the entire code in Command pane ending with Exec SP???
example -

DECLARE @SQL NVARCHAR(MAX)

SELECT @SQL =
REPLACE(
CAST(
(
SELECT 'USE ' + QUOTENAME(name) +';' + CHAR(13) + CHAR(10) +
'EXECUTE schema.procedure;'+CHAR(13)+CHAR(10)
FROM sys.databases WHERE name NOT IN ('master','msdb','model','tempdb')
FOR XML PATH('')
) AS NVARCHAR(MAX)
),
'& # x 0 D ;',CHAR(13) + CHAR(10)
)
--SELECT @SQL

Exec pr_Index @SQL


is this correct???

************************************
Every Dog has a Tail !!!!! :-D
anthony.green
anthony.green
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6091 Visits: 6077
Use my code, the only thing you need to do is to replace the the text schema.procedure with the name of your procedure eg. dbo.thisismyprocedure

Then remove the spaces between the '& # x 0 D ;'

The last step should be exec sp_executesql @sql do not change that line.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)Old Hand (300 reputation)

Group: General Forum Members
Points: 300 Visits: 690
I got it, but one question while copying this is command pane.. there we have to select the database also?? by defauklt it is Master, what should i choose???

************************************
Every Dog has a Tail !!!!! :-D
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search