Tuesday, November 11, 2008

sp is used for get split string from coma

This Stored Procedure is used for get values from CSV.
e.g a,b,c,d,e,f is split by coma


create proc [dbo].[ufn_CountChar] ( @pInput VARCHAR(1000), @pSearchChar CHAR(1) )
as
BEGIN

/*DECLARE @vInputLength INT*/
DECLARE @vIndex INT
DECLARE @vCount INT
DECLARE @s varchar(2)
DECLARE @str varchar(10)
declare @SubStr varchar(1000)

set @SubStr=''
SET @vCount = 0
SET @vIndex = 1
/*SET @vInputLength = LEN(@pInput)*/
set @str=''

WHILE @vIndex <= len(@pInput)
BEGIN
IF SUBSTRING(@pInput, @vIndex, 1) = @pSearchChar
BEGIN
SET @vCount = @vCount + 1
set @SubStr = substring(@pInput,len(@SubStr),len( @str))
select @str
set @str=''
END
else
BEGIN
set @s=SUBSTRING(@pInput,@vindex,1)
set @str=@str+@s
print ' i m in else part'+ space(3)+ @str
if( @vIndex = len(@pInput))
begin
select @str
end

END
SET @vIndex = @vIndex + 1

END

--select @str


END
GO

ufn_CountChar 'afd,hghg,hgjgh',','

Thankks
helpondesk team

http://aspalliance.com/1125_Dynamically_Templated_GridView_with_Edit_Delete_and_Insert_Options.all

http://www.dotnetcurry.com/ShowArticle.aspx?ID=107&AspxAutoDetectCookieSupport=1

No comments: