IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_AplazarProgramaciones]') AND type in (N'P', N'PC'))
BEGIN
	execute('
			CREATE PROCEDURE [dbo].[_AplazarProgramaciones]
				@p_id_programacion as int,
				@p_id_tipoProgramacion as int,
				@p_id_motivoCancelacion as int,
				@p_id_usuario as int, 
				@p_eid as varchar(45)
			AS
			BEGIN
				SET NOCOUNT ON;

				update ort_programacion 
					set id_tipoProgramacion = @p_id_tipoProgramacion, 
						id_motivoCancelacion = @p_id_motivoCancelacion,
						id_usuario_modifico = @p_id_usuario,
						fechaModificacion = GETDATE()
					where id = @p_id_programacion or id_programacion = @p_id_programacion
				
				select ''''
			END
	')
END