开发者

Passing select statement as parameter to scalar function in SQL

I have scalar function which takes an integer as argument and return an integer too. I was trying t开发者_如何学Pythono use this function by passing a parameter as a select statement which looks like :

select dbo.scalarFunc(select si.ID from table1 si where version = 9)

It would not let me do it. I tried cast but still did not work. Can anyone tell me if I can use select inside like this or not?


I think a good way to write this is :

select dbo.scalarFunc(table1.ID) from table1 where version = 9

And if you want to use it later :

select * from table2 where ID = (select dbo.scalarFunc(table1.ID) from table1 where version = 9)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜