
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_grid_nm_countries_postcodes]
	@country_code ais_code_short = '%',
	@dpi_code ais_code_short = '%',
	@postcode_code ais_code_medium = '%',
	@city nvarchar(64) = '%'
AS


	select	*
	from	nm_countries_postcodes
	where	( @country_code = '%' or nmpc_country_code like @country_code)
	and		( @dpi_code = '%' or nmpc_dpi_code like @dpi_code)
	and		( @postcode_code = '%' or nmpc_postcode_code like @postcode_code)
	and		( @city = '%' OR
							(	isnull(nmpc_l1, '') like @city
							or	isnull(nmpc_l2, '') like @city
							or	isnull(nmpc_l3, '') like @city )
			)




GO
