0

I have a function that has a parameter varchar.

I want to call the function and pass select result to function like

Select * from dbo.myfunc(select name from users)

But I get this ERROR:

Incorrect syntax near ')'

What can I do?

Robert
  • 25,425
  • 8
  • 67
  • 81
Psar Tak
  • 682
  • 1
  • 9
  • 27
  • 2
    Your error is because a function call needs brackets as does a subquery. You only have one set. However, passing a subquery to a function that has a varchar parameter is fundamentally wrong anyway. @Parado's answer looks pretty good to me. – Dan Bracuk May 11 '15 at 11:35

2 Answers2

2

Maybe like this:

select dbo.myfunc(name) from users
Robert
  • 25,425
  • 8
  • 67
  • 81
1

Use apply:

Select f.*
from users u cross apply
     dbo.myfunc(u.name) as f;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786