sp_update_job and dbcc question

  • Hello Guys and Girls,

    I was wondering if anyone can explain what the following statements does:

    ...

    " exec msdb.dbo.sp_update_job @job_name='dvjob_MyJobName', @enabled=0" + NL +

    " dbcc shrinkdatabase(@dbname, notruncate)" + NL +

    " exec msdb.dbo.sp_update_job @job_name='dvjob_MyJobName', @enabled=1" + NL

    ... the above is an extraction of some java code. I read the storedproc called sp_update_job, but it is all geek to me at the moment. What does it mean to enable or disable the job, what happens when this is done?

    The aim is to understand what this does, in order to make a decision how to progress with my current project...:w00t:

  • Hello,

    I think this code is just to prevent the Job from running while a (DBCC) Shrink-Database is in progress i.e.

    1) Disable job

    2) Shrink the database

    3) Re-enable the job

    When a job is disabled (Enabled = 0) it will not run on its schedule(s).

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

  • John is right. I just wanted to comment that shrinking your database is not normally a good idea. There is usually a reason why it grew and it will grow again.

  • Thank you for your input - this solves my problem, as I can now continue with my project...:-)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply