Tsql T-SQL如何在SELECT查询中运行过程/函数?

Tsql T-SQL如何在SELECT查询中运行过程/函数?,tsql,Tsql,我现在无法检查它(现在没有编译器),但该查询会执行吗 select myTable.id_customer, [my_procedure_or_function](myTable.id_customer) from myTable group by myTable.id_customer 该过程/函数返回数值(18,0)或NULL 总而言之,我需要从该表中选择distinctid\u customer,对于该id-获取当前与该id\u customer关联的数字/空值,从语法上讲,它适用于

我现在无法检查它(现在没有编译器),但该查询会执行吗

select myTable.id_customer, [my_procedure_or_function](myTable.id_customer)

from myTable

group by myTable.id_customer
该过程/函数返回数值(18,0)或NULL


总而言之,我需要从该表中选择distinctid\u customer,对于该id-获取当前与该id\u customer关联的数字/空值

,从语法上讲,它适用于标量UDF,但不适用于存储过程

select myTable.id_customer, mySchema.myFunction(myTable.id_customer) As myAlias
from myTable
group by myTable.id_customer

然而,根据标量UDF所做的工作,可能会有更高性能的方法。例如,如果它在另一个表中查找某个值,通常最好将此逻辑直接内联到查询中。

正如Martin Smith所说,如果它是标量用户定义函数(UDF),它不包含与“myTable.id\u customer”相同类型的单个参数,而不是表格或存储过程,并且执行连接具有UDF的执行权限,那么它应该可以正常工作