我想将一个标量值的select查询作为参数传递给像这样的函数:
select * from dbo.ftLatestOrderLines(select max(id) from [orders])
db server抛出此错误:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'.
是否有解决方法将查询作为参数传递?
答案 0 :(得分:1)
尝试在子查询周围添加另一组括号...
select * from dbo.ftLatestOrderLines((select max(id) from [orders]))