August 12, 2008 at 1:10 pm
I need to write a function...which has two parameters one is the unique id upon which we will get the value which is a string like(323,43,65,767) and the other parameter is a varchar(20) ...so now we need to look whether this string comed under second parameter type or not if it comes then we need to display the description of that second parameter ....
set @x=select string from table1
where u_id=@parameter1
so we get the string in @x =(323,43,65,767)
so i have other table called lookup
so i have data in that like
name string
abc 323
def 43
cdsd 767
dfdf 4343
so i need to compare it with that and the output of that function should be like
as we have 323,43,767 i need to return
abc;def;cdsd as my output please let me know how ccan i do that ....
Thanks,
Chinna
Its the Journey which gives you Happiness not the Destination-- Dan Millman
August 12, 2008 at 1:27 pm
I would have the UDF return a table with a list of the string values and then join on the UDF. Check out this article for splitting a delimited list into a table: http://www.sqlservercentral.com/articles/Advanced+Querying/2547/
Once you have the function written you can join on it like this:
Select
L.*
From
lookup L Join
dbo.fnReturnTable(@parameter) T On
L.string = T.string
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply