开发者

T-SQL Using a varchar in a select statement

开发者 https://www.devze.com 2023-04-04 14:14 出处:网络
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百科esu

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')

0

精彩评论

暂无评论...
验证码 换一张
取 消