I need to use the return of a function (VARCHAR) as columns in a select statement. For example:
我需要在select语句中使用函数返回(VARCHAR)作为列。例如:
A function fn1 returns a varchar @result='Alice,Bob'. How can I do a query using @result in a select statement, e.g:
函数fn1返回varchar @ result ='Alice,Bob'。如何在select语句中使用@result进行查询,例如:
SELECT @result FROM B
and obtain the records of the columns Alice and Bob of another Table.
并获取另一个表的Alice和Bob列的记录。
Thanks in advance
提前致谢
1 个解决方案
#1
3
Try exec('select ' + fn_1() + ' from T')
尝试exec(从T'''选择'+ fn_1()+')
#1
3
Try exec('select ' + fn_1() + ' from T')
尝试exec(从T'''选择'+ fn_1()+')