none
SQL 2008 user function to return row values?

    Question

  • Hi, I have SQL 2008 and I would like to create user-define function which return row value from a table in variable.
    For example
    CREATE FUNCTION dbo.myfunction
    @funpara parameter
    BEGIN
      DECLARE @ret1 varchar(max)
      SELECT * FROM MyTable1 WHERE Col1 IN @funpara 
      RETURN @ret1
    END

    If I run TSQL SELECT dbo.myfunction ('valepass1') and then function must return multiple value contacted by comma (,) from MyTable1 like   'value1, value2, value3' 

    Any idea how to create function to retrun multiple values concat by comma string. Thanks. 

    Saturday, March 19, 2011 9:24 AM

Answers