39 lines
2.2 KiB
Transact-SQL
39 lines
2.2 KiB
Transact-SQL
USE [site_fuchs]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[ott_csv_contains] Script Date: 02.12.2020 21:05:05 ******/
|
|
DROP FUNCTION [dbo].[ott_csv_contains]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[ott_csv_contains] Script Date: 02.12.2020 21:05:06 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date, ,>
|
|
-- Description: <Description, ,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[ott_csv_contains]
|
|
(
|
|
@text varchar(500)
|
|
,@fragment varchar(500)
|
|
)
|
|
RETURNS bit
|
|
AS
|
|
BEGIN
|
|
DECLARE @RET bit;
|
|
|
|
-- Will be true
|
|
-- if any of the fragments exist in the list of text-items
|
|
|
|
WITH texts as (SELECT * FROM string_split(ISNULL(@text,''), ','))
|
|
,fragments as (SELECT * FROM string_split(ISNULL(@fragment,''), ','))
|
|
SELECT @RET = CASE WHEN EXISTS (SELECT * FROM texts JOIN fragments ON texts.[value] = fragments.[value]) THEN 1 ELSE 0 END;
|
|
|
|
RETURN @RET;
|
|
|
|
END
|
|
GO
|
|
ALTER AUTHORIZATION ON [dbo].[ott_csv_contains] TO SCHEMA OWNER
|
|
GO
|