sqlserver区分大小写

CREATE FUNCTION StrComp(@Str1 VARCHAR(50),@Str2 VARCHAR(50))
RETURNS INTEGER
AS
BEGIN
DECLARE @i INTEGER
DECLARE @y INT
SET @i=0
SET @y=1
DECLARE @iLen INT
SET @iLen = LEN(LTRIM(RTRIM(@Str1)))
IF LEN(LTRIM(RTRIM(@Str1))) < LEN(LTRIM(RTRIM(@Str2)))
SET @iLen = LEN(LTRIM(RTRIM(@Str2)))
WHILE (@i < @iLen)
BEGIN
IF (ASCII(SUBSTRING(@Str1,@i+1,1))=ASCII(SUBSTRING(@Str2,@i+1,1)))
SET @i = @i +1
ELSE
BEGIN
SET @y=0
BREAK
END
END
RETURN @y
END


dbo.StrComp(Field1,'aAbB')=1

 

posted @ 2012-12-10 10:53  一千零一夜  阅读(263)  评论(0编辑  收藏  举报