I am writing SQL Server deployment scripts which create SQL Server job automatically on a specific SQL Server server/instance. I have found that I can extract the sql statem
I was coming across the same problem today and how I tackle it is so simple Do the following
Create a stored proc that creates the job with parameter @serverName nvarchar(128)
Create Proc CreateAJob(@serverName nvarchar(128))
Now easy, you can get the server name using the following
Declare @serverName nvarchar(128)
SELECT @servername=@@SERVERNAME
Execute the stored proc to create your job
EXEC CreateJob @serverName
That is it.
I am using visual studio db project and I did steps 2 and 3 int the postdeployment script