I need to use the return of a function (VARCHAR) as columns in a select statement. For example:
A function fn1 returns a varchar @result='Alice,Bob'. How can I do a query using @r开发者_JAVA百科esult in a select statement, e.g:
SELECT @result FROM B
and obtain the records of the columns Alice and Bob of another Table.
Thanks in advance
Try exec('select ' + fn_1() + ' from T')
精彩评论