November 16, 2011 at 11:48 am
Hi,
I want a code for how to create a seperate function outside,i have a parameter in my procedure called @principal and @firm,for tehse two
i have to create a function outside with multi selection option in drop down list.just creating a seperate function and calling that in procedure.
can anyone help me how to write a code for these two parameters and how to call in SP.
November 16, 2011 at 12:11 pm
What is the question? Are you trying to create a function that receives two parameters? If you can clearly explain what you are trying to do we can help.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 16, 2011 at 12:16 pm
You could try something similar to the following:
create function [dbo].[Split_Values]
(
@String varchar(4000)
,@Delimiter varchar(1)
)
returns @Split_Values table(String_Value varchar(200))
as
begin
insert into @Split_Values
(
String_Value
)
(
selectsubstring
(
@Delimiter + @String + @Delimiter
,N + 1
,charindex(@Delimiter,@Delimiter + @String + @Delimiter,N + 1) - N - 1
) as String_Value
fromdbo.Tally
whereN < len(@Delimiter + @String + @Delimiter)
and substring(@Delimiter + @String + @Delimiter,N,1) = @Delimiter
)
return
end
For the above function, you will need a "Tally" table...read up on that...it will be useful in many other situations as well.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply