Tricky Query to find the First lower case character in a String in SQL Server
Declare @i int , @loop int , @str varchar(100) = 'TEST_lOwerCase'
IF EXISTS
(
SELECT *
FROM tempdb.dbo.sysobjects
WHERE ID = OBJECT_ID(N'tempdb..#Temp')
)
BEGIN
DROP TABLE #Temp
END
create table #Temp (id int)
select @i = LEN(@str)
print @i
set @loop = 1
while(@loop <= @i)
BEGIN
if((ascii(SUBSTRING(@str,@loop,1))>=97) and (ascii(SUBSTRING(@str,@loop,1))<=122))
insert into
#Temp values (@loop)
set @loop = @loop + 1
END
select MIN(id) from #Temp
GO
Comments
Post a Comment