create function charm_data (@charmrsntext varchar(50))
RETURNS varchar(8)
AS
BEGIN
--create table test
--(position int , value char(1))
declare @charm table
(position int , value char(1))
declare @len int
declare @p int
declare @rsntext varchar(50)
select @len=len(@charmrsntext)--from jobbypassobj
set @p=1
select @rsntext=@charmrsntext
while (@p<=@len)
begin
insert into @charm
values(@p, substring(@rsntext,@p,1)) --- String Devided into char
set @p=@p+1
end
--select position,value from @charm where isnumeric(value)=1
declare @pos int
declare @val varchar(1)
declare @charm_data varchar(10)
declare @charm_dataF varchar(8)
declare @flag int
declare @cnt int
set @charm_data=''
set @cnt=1
declare charm_cursor cursor for
select position,value from @charm where isnumeric(value)=1
open charm_cursor
FETCH Next from charm_cursor into @pos,@val
while @@FETCH_STATUS=0
begin
set @flag=@pos
set @charm_data=@charm_data+@val
if @cnt>=5
set @charm_dataF=@charm_data
--print @charm_data
FETCH Next from charm_cursor into @pos,@val
if @pos=@flag+1 --or @cnt>=5
begin
set @cnt=@cnt+1
-- print @pos
-- print @flag
-- print 'Purna'
-- print @cnt
end
else
begin
set @cnt=1
set @charm_data=''
end
end
-- print @flag
-- print @cnt
CLOSE charm_cursor
DEALLOCATE charm_cursor
--drop table test
return @charm_dataF
END
RETURNS varchar(8)
AS
BEGIN
--create table test
--(position int , value char(1))
declare @charm table
(position int , value char(1))
declare @len int
declare @p int
declare @rsntext varchar(50)
select @len=len(@charmrsntext)--from jobbypassobj
set @p=1
select @rsntext=@charmrsntext
while (@p<=@len)
begin
insert into @charm
values(@p, substring(@rsntext,@p,1)) --- String Devided into char
set @p=@p+1
end
--select position,value from @charm where isnumeric(value)=1
declare @pos int
declare @val varchar(1)
declare @charm_data varchar(10)
declare @charm_dataF varchar(8)
declare @flag int
declare @cnt int
set @charm_data=''
set @cnt=1
declare charm_cursor cursor for
select position,value from @charm where isnumeric(value)=1
open charm_cursor
FETCH Next from charm_cursor into @pos,@val
while @@FETCH_STATUS=0
begin
set @flag=@pos
set @charm_data=@charm_data+@val
if @cnt>=5
set @charm_dataF=@charm_data
--print @charm_data
FETCH Next from charm_cursor into @pos,@val
if @pos=@flag+1 --or @cnt>=5
begin
set @cnt=@cnt+1
-- print @pos
-- print @flag
-- print 'Purna'
-- print @cnt
end
else
begin
set @cnt=1
set @charm_data=''
end
end
-- print @flag
-- print @cnt
CLOSE charm_cursor
DEALLOCATE charm_cursor
--drop table test
return @charm_dataF
END
Fatafati Bhai! Cholbe. TechGuru
ReplyDelete