I am trying to script an SQL server agent job so that one script can be run on multiple servers to set up the same job. we have the same users and will use the same job name on the different servers. however there is one part that I am struggling with, and that is getting the server details for the relevant servers pulled through as part of the script. the initial script has something like this:
@command=N'/ISSERVER "\"\SSISDB\SSP SSIS\step1.dtsx\"" /SERVER (servername) /Par "\"$ServerOption::LOGGING_LEVEL(Int16)\"";1 /Par "\"$ServerOption::SYNCHRONIZED(Boolean)\"";True /CALLERINFO SQLAGENT /REPORTING E',
I am aware that I could replace our server name with localhost, however then you can only view the configuration settings from the server that the job will run on, which isn't ideal as not everybody has access to all server, especially the production server.
I was hoping to use "/SERVER' + @@SERVERNAME + '/Par" but in breaking the string for the @command line I receive an incorrect syntax error at the + symbol and I can't find any way of getting this to accept this command.