CHECK WHETHER ALL CHARACTERS IN THE INPUT STRING ARE OF UPPER CASE OR NOT.
IF YES THEN RETURN 1
ELSE
RETURN -1

ALTER PROC CHECKSTRINGFORCAPTIALLETTERS
(
@str Varchar(250)
)
AS
BEGIN
DECLARE @return AS INT , @position AS INT , @MyValue INT
SET @position = 1
SET @return = -1
SET @MyValue = 0
WHILE @position <= DATALENGTH(@str)
BEGIN
IF ASCII(SUBSTRING(@str, @position, 1)) BETWEEN 65 AND 90
SET @return = 0
ELSE
SET @return = 1

SET @position = @position + 1
PRINT @return

IF @return = 1
BEGIN
SET @MyValue = -1
GOTO Himanshu
END
ELSE
BEGIN
SET @MyValue = 1
END
END
Himanshu: SELECT @MyValue
END

EXEC CHECKSTRINGFORCAPTIALLETTERS ‘HIMsNSHU’

Pawan Kumar
Pawankkmr@hotmail.com

Advertisements