SQL Server VARCHAR' is not a recognized built-in function name

vtwuwzda  于 2023-11-16  发布在  其他
关注(0)|答案(1)|浏览(106)

Here is my mssql function code.

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

It returns, VARCHAR' is not a recognized built-in function name.

ulmd4ohb

ulmd4ohb1#

CAST(VARCHAR(5),OP.ProductId)

should be

CAST(OP.ProductId as VARCHAR(5))

See the MSDN docs .

相关问题