Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR ALTER FUNCTION ufn_IsWordComprised(@setOfLetters VARCHAR(20), @word VARCHAR(20))
- RETURNS BIT
- AS
- BEGIN
- DECLARE @i INT = 1;
- DECLARE @Checker BIT = 0;
- WHILE @i <= LEN(@word)
- BEGIN
- DECLARE @SetLetter CHAR(1) = SUBSTRING(@word, @i, 1);
- DECLARE @j INT = 1;
- WHILE @j <= LEN(@setOfLetters)
- BEGIN
- DECLARE @WordLetter CHAR(1) = SUBSTRING(@setOfLetters, @j, 1);
- IF @SetLetter = @WordLetter
- BEGIN
- SET @Checker = 1;
- BREAK;
- END
- SET @j += 1;
- SET @Checker = 0;
- END
- IF(@Checker = 0)
- RETURN 0;
- SET @i +=1;
- END
- RETURN 1;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement