Aliendreamer

why they make me do it with sql

Jun 15th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.39 KB | None | 0 0
  1. CREATE FUNCTION ufn_IsWordComprised(@setOfLetters VARCHAR(MAX), @word VARCHAR(MAX))
  2. RETURNS BIT
  3. AS
  4. BEGIN
  5.   DECLARE @why BIT = 0;
  6.   DECLARE @cindex INT = 1;
  7.   DECLARE @cchar CHAR;
  8.  
  9.   WHILE(@cindex <= LEN(@word))
  10.   BEGIN
  11.  
  12.     SET @cchar = SUBSTRING(@word, @cindex, 1);
  13.     IF(CHARINDEX(@cchar, @setOfLetters) = 0)
  14.       RETURN @why;
  15.     SET @cindex += 1;
  16.  
  17.   END
  18.  
  19.   RETURN @why+ 1;
  20.  
  21. END
Advertisement
Add Comment
Please, Sign In to add comment