USE [Database]

IF OBJECT_ID('[Functions].[does_product_exist_with_product_type_id]') IS NOT NULL
  DROP FUNCTION [Functions].[does_product_exist_with_product_type_id];
GO
CREATE FUNCTION [Functions].[does_product_exist_with_product_type_id](
  @product_type_id AS INT
)
RETURNS BIT
AS
BEGIN
  IF EXISTS (
    SELECT *
    FROM [Tables].[products]
    WHERE [product_type_id] = @product_type_id
  )
    RETURN CAST(1 AS BIT);
  RETURN CAST(0 AS BIT);
END