我已經更新了代碼的建議,但現在我得到一個新的錯誤標量函數:返回地址
--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。 。 。你應該問另一個問題,並展示如何調用函數。 –