Job Step Properties of SQL Server Agent job in SSMS does not match generated TSQL code

  • The Job Step Properties of SQL Server Agent job in SSMS does not match generated TSQL code

    when I select "Script Job as create to new query window" for the same Agent job.

    In the job I am looking at, the job step properties screens do NOT show a database name, just the TSQL command

    being run. However, when I look at the TSQL generated by the "Script Job as create..." for these job steps,

    the sp_add_jobstep command options DO show a database_name. For example:

    EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Datawhs Update Stats',

    @step_id=2,

    @cmdexec_success_code=0,

    @on_success_action=3,

    @on_success_step_id=0,

    @on_fail_action=2,

    @on_fail_step_id=0,

    @retry_attempts=0,

    @retry_interval=0,

    @os_run_priority=0, @subsystem=N'TSQL',

    @command=N'sp_updatestats',

    @database_name=N'Datawhs',

    @flags=0

    However, when I look at the Job Step Properties of this step in the Agent job, the "Database:" entry

    is not filled in, only the "Command:" entry (in this case sp_updatestats). How can the job step properties

    have a blank database name and yet the sp_add_jobstep entry have it filled in?

  • I had the same issue. Please check and make sure that the database name specified in the job step matches the database name specified in the SQL Server instance (CASE SENSITIVE). It seems that if the database name with case sensitivity does not exactly match the name on the server it will show a blank. This appears to have been corrected in SSMS 2012.

  • Thank you! It was indeed the "case" of the database name in the job step versus the name in the instance. If the database name's case matched the name in the instance, it showed. If not, it did not show. This job is on four servers, and one had the name of the database in the same case, and indeed the database showed up in the properties of the job step. The other three it did not (database had different case).

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

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