Delete SQL Job using TSQL

Below a small piece of code to delete the SQL Job from Agent using TSQL. This code will make sure the job is deleted/dropped cleanly.

USE [msdb]
GO
DECLARE @MyJobID uniqueidentifier
select @MyJobID = job_id from sysjobs where name = 'JOBNAMETOBEDELETED'
EXEC msdb.dbo.sp_delete_job @job_id=@MyJobID, @delete_unused_schedule=1
GO