Advertisement
aslv

Problem 7 - Define Functoion - Functions,Triggers and Transa

Oct 17th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.46 KB | None | 0 0
  1. ALTER FUNCTION ufn_IsWordComprised(@SetOfLetters VARCHAR(50), @Word VARCHAR(50))
  2. RETURNS BIT
  3. AS
  4. BEGIN
  5.     DECLARE @IsTrue BIT =1
  6.     DECLARE @Counter INT =1
  7.     DECLARE @Letter VARCHAR(1)
  8.     SET @SetOfLetters = LOWER(@SetOfLetters)
  9.     SET @Word = LOWER(@Word)
  10.     WHILE @Counter < LEN(@Word)
  11.     BEGIN
  12.         SET @Letter = SUBSTRING(@SetOfLetters,@Counter,1)
  13.         IF CHARINDEX(@Letter,@Word) = 0
  14.         BEGIN
  15.             SET @IsTrue = 0
  16.             BREAK
  17.         END
  18.         SET @Counter+=1
  19.     END
  20.     RETURN @IsTrue
  21. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement