cagin
cagin

Reputation: 5920

VARCHAR' is not a recognized built-in function name

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.

Upvotes: 5

Views: 12815

Answers (1)

D&#39;Arcy Rittich
D&#39;Arcy Rittich

Reputation: 171401

CAST(VARCHAR(5),OP.ProductId)

should be

CAST(OP.ProductId as VARCHAR(5)) 

See the MSDN docs.

Upvotes: 8

Related Questions