我已经更新了代码的建议,但现在我得到一个新的错误标量函数:返回地址
--The function
Create Function udf_GetCustomerAddress
(@CustomerID varchar)
Returns varchar
As
Begin
declare @CustomerAddress varchar
select
@CustomerAddress = c.CompanyName, c.Address, c.City,
c.StateOrRegion, c.PostalCode, c.CustomerID
from
Customers c
where
c.CustomerID = @CustomerID
Return @CustomerAddress
End
再次感谢在:
Msg 141, Level 15, State 1, Procedure udf_GetCustomerAddress, Line 31
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
我的代码粘贴下面提前!
不错!谢谢@Gordon Linoff – user7879707
当我调用函数时,仍然出现错误: Msg 4104,Level 16,State 1,Line 62 多部分标识符“dbo.udf_GetCustomerAddress”无法绑定。 我打这样的功能: select dbo.udf_GetCustomerAddress'company ID'as'Company Address' 有什么想法? – user7879707
@ user7879707。 。 。你应该问另一个问题,并展示如何调用函数。 –