creating a udf

  • guys i need help creating a udf which takes a string and comma separates them, any help is welcome i want to use the udf in a report which will accept a multi valued parameter

  • Are you talking about a delimited string split? Like this:

    1,2,3,4 to

    1

    2

    3

    4

  • nope but 1 2 3 4

    into 1, 2, 3, 4

  • klineandking (2/5/2010)


    nope but 1 2 3 4

    into 1, 2, 3, 4

    so:

    select replace('1 2 3 4',' ',',')

    Is that what you are looking for?

  • much more like

    1

    2

    3

    4

    into 1,2, 3, 4

  • i want it to take a tabular result and turn it into a string that is from

    1

    2

    3

    4

    int 1, 2, 3, 4

  • Will this help get you started:

    create table #testtab (

    intval int

    );

    insert into #testtab

    select 1 union all

    select 2 union all

    select 3 union all

    select 4;

    select

    STUFF((select ',' + cast(intval as varchar) from #testtab for xml path('')),1,1,'')

  • ll give it a try and give you feedback thanks

Viewing 8 posts - 1 through 7 (of 7 total)

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