开发者

T-SQL Using a varchar in a select statement

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜