Can an update query be automated?

  • I run the following update on a weekly basis.  Can it be setup to happen automatically?

     

    update table1

    set

    table1.column1 = (rtrim(c.column_name) = ' ' + c.column_name),

    table1.column_name = b.column_name

    from table1 a,

    table2 b,

    table3 c

    where a.column_name = b.column_name

    and b.column_name = c.column_name

     

  • Open EM. Expand this item:

    Management->SQL Server Agent->Jobs

    Right-click on Jobs, select New Job. See the "Steps" tab, create a new step and observe where a SQL statement can be pasted. This is how you'd schedule your SQL statment to run automatically every week.

     

  • Just a hint: you can paste a long complicated SQL into the command window of a job step, but it is hard to maintain it. It is much better to create a stored procedure with the code, and use the agent(job) to start the procedure (Step->Command will then be just EXECUTE procedurename parameters).

    HTH, Vladan

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

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