VARCHAR'不是公认的内置函数名称

时间:2012-10-10 16:46:02

标签: sql-server function

这是我的mssql函数代码。

 ALTER function [dbo].[UF_GetOrderProducts]
(
  @OrderId int
)
returns varchar(500)
as
begin

return
  (
  select CAST(VARCHAR(5),OP.ProductId)+'<br/>'
  from OrderProduct as OP

  where OP.OrderId = @OrderId
  for xml path(''), type
  ).value('.', 'varchar(500)')
end

返回VARCHAR' is not a recognized built-in function name.

1 个答案:

答案 0 :(得分:6)

CAST(VARCHAR(5),OP.ProductId)

应该是

CAST(OP.ProductId as VARCHAR(5)) 

请参阅MSDN docs