small function issue

  • 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

  • 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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply