
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_nm_risks_movements]
	@movement_code ais_code_short,
	@type_add smallint = -1, -- -1 = all, 1 = on, 0 = off
	@type_edit smallint = -1, -- -1 = all, 1 = on, 0 = off
	@type_retire smallint = -1 -- -1 = all, 1 = on, 0 = off
AS
BEGIN

	SET NOCOUNT ON

	SELECT	*
	FROM nm_risks_movements
	WHERE	(@movement_code = '%' OR rmvt_movement_code = @movement_code)
			and (@type_add = -1 or rmvt_type_add = @type_add)
			and (@type_edit = -1 or rmvt_type_edit = @type_edit)
			and (@type_retire = -1 or rmvt_type_retire = @type_retire)

END

GO
