Batch job to update a SP on independent machines

  • We have 20+ machines that are running SQL 2008 Express. We need to add a SP & table and update existing SP's on each machine. Is there anyway to do this with out me having to touch each machine? Anyone know of a batch job that would allow this?

  • Why???

  • My suggestion:

    Create a .bat batch file on a computer and create a SQLCMD line for each server instance that you need to run it on.

    For instance:

    sqlcmd -S ServerName1\SQLEXPRESS -E -i \\someserver\c$\somedir\SQLExpressStuff.sql -o \\someserver\c$\somedir\ServerName1_SQLExpressStuff.txt

    sqlcmd -S ServerName2\SQLEXPRESS -E -i \\someserver\c$\somedir\SQLExpressStuff.sql -o \\someserver\c$\somedir\ServerName2_SQLExpressStuff.txt

    Run the same sql script, just run it on the different servers (here, ServerName1, and ServerName2). Save the output log file to a consolidated location, all to the same server and directory, just name them different so that they won't overwrite each other.

    Just put everything you want to do in the .sql script.

    The -E will use Windows Authentication.

    Haven't tested, but should work, as long as it allows UNC naming for the files.

  • You can also register all sql server instances in SQL Server Management studio under one group and then can run a single query on that group which will be executed on all sql Server instances.

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

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