Technical Article

Function to Split Multivalued Parameter

,

This Function is written to split Multivalued Parameter passed by Reporting Services 2005.

/**********************************************************
CREATED BY:HARI
CREATED ON:JUNE 21st, 2007
PURPOSE:To Split Multivalued Parameter

SELECT * FROM dbo.GetSplitedValues('1,3,4,6,7,8')
**********************************************************/ALTER Function [dbo].[GetSplitedValues]
(
@CommaSeparatedString varchar(8000)
)
RETURNS @Table Table (ID int)
Begin
Declare @TempStr varchar(8000)
Set @TempStr = @CommaSeparatedString + ','
While Len(@TempStr) > 0 
Begin 
Insert Into @Table Select SubString(@TempStr,1,CharIndex(',',@TempStr)-1)
Set @TempStr = Right(@TempStr,Len(@TempStr)-CharIndex(',',@TempStr))
End
Return
End

Rate

2.44 (9)

You rated this post out of 5. Change rating

Share

Share

Rate

2.44 (9)

You rated this post out of 5. Change rating