ulivegenov

/* 07.Define Function*/

Oct 11th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. /* 07.Define Function*/
  2. CREATE FUNCTION ufn_IsWordComprised(@SetOfLetters VARCHAR(MAX) , @Word VARCHAR(MAX))
  3. RETURNS BIT
  4. BEGIN
  5. DECLARE @index INT = 1;
  6. DECLARE @result BIT = 1;
  7. WHILE(@index <= LEN(@Word))
  8. BEGIN
  9. IF(CHARINDEX(SUBSTRING(@WORD, @index, 1), @SetOfLetters, 1) = 0)
  10. BEGIN
  11. SET @result = 0;
  12. RETURN @result;
  13. END
  14. SET @index += 1;
  15. END
  16.  
  17. RETURN @result;
  18. END
Advertisement
Add Comment
Please, Sign In to add comment