Something like this, perhaps?
DECLARE @text NVARCHAR(400) = 'this is a cat'
DECLARE @search NVARCHAR(400) = 'a cat'
SELECT t.value
FROM STRING_SPLIT(@text, ' ') t
join STRING_SPLIT(@search, ' ') s
on t.value = s.value
WHERE RTRIM(t.value) <> '' and RTRIM(s.value) <> '';
Then you can compare the if the count of this result and your search split count is equal.
You'll need Sql-server 2016 or higher for STRING_SPLIT
to work.
In case of lower versions of sql, you'll need to create a UDF to split a string. One like this:
CREATE FUNCTION dbo.fnSplit(
@sInputList VARCHAR(8000) -- List of delimited items
, @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
) RETURNS @List TABLE (item VARCHAR(8000))
BEGIN
DECLARE @sItem VARCHAR(8000)
WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
BEGIN
SELECT
@sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
@sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))
IF LEN(@sItem) > 0
INSERT INTO @List SELECT @sItem
END
IF LEN(@sInputList) > 0
INSERT INTO @List SELECT @sInputList -- Put the last item in
RETURN
END
GO
And the above query becomes:
DECLARE @text NVARCHAR(400) = 'this is a cat'
DECLARE @search NVARCHAR(400) = 'a cat'
SELECT t.Item
FROM fnSplit(@text, ' ') t
join fnSplit(@search, ' ') s
on t.Item = s.Item