Skip to content

Instantly share code, notes, and snippets.

@LitKnd
Last active April 24, 2019 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LitKnd/274f48fae50327e87d7d05022db53473 to your computer and use it in GitHub Desktop.
Save LitKnd/274f48fae50327e87d7d05022db53473 to your computer and use it in GitHub Desktop.
/*
* Use this Post-Deployment script to perform tasks after the deployment of the project.
* Read more at https://www.red-gate.com/SOC7/post-deployment-script-help
*/
--This is terrible tsql, it's written for a quick repro only
DECLARE @name NVARCHAR(2000);
IF
(
SELECT COUNT(*)
FROM msdb.dbo.sysjobs
WHERE name LIKE N'Test job created at%'
) > 0
BEGIN
SELECT @name = name
FROM msdb.dbo.sysjobs
WHERE name LIKE N'Test job created at%';
EXEC msdb.dbo.sp_delete_job @job_name = @name;
END;
SET @name = N'Test job created at ' + CAST(SYSDATETIME() AS VARCHAR) + N' by SCA';
EXEC msdb.dbo.sp_add_job @job_name = @name,
@enabled = 0,
@description = N'Testing job in post deployment script',
@owner_login_name = N'sa';
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment