简体   繁体   中英

SQL CAST(int as varchar) throws error

Good evening,

I'm trying to convert an int to a varchar using the CAST() function but it gives me the following error:

syntax error, unexpected VARCHAR

and this is the code

CAST(p2v as varchar)

and i also tried

CAST(p2v as varchar(MAX))

I got the same problem when i try using CONVERT()

It must be char , not varchar

The type for the result can be one of the following values:

  • BINARY[(N)]
  • CHAR[(N)]
  • DATE
  • DATETIME
  • DECIMAL[(M[,D])]
  • SIGNED [INTEGER]
  • TIME
  • UNSIGNED [INTEGER]

From http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_cast

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM