CAST and CONVERT to varchar not working


#1

why CAST(account_seq AS char) is compiling fine while CAST(account_seq AS varchar) is not compiling ???

what will be the memsql syntax for this sybase sentence: convert(varchar(8),@bnfcr_seq_nbr)


#2

See https://docs.memsql.com/sql-reference/v6.7/convert/. The CAST function doesn’t fully specify the type - it lets you convert to a general string, not a specific string type. If you want to convert to a specific type, use the :> typecast operator described on that page, e.g. val :> varchar(8).


#3

what about CONVERT, is the same issue with it ?

what will be the memsql syntax for this sybase sentence: CONVERT(varchar(8),@bnfcr_seq_nbr)


#4

Use the :> typecast operator as I described above:

@bnfcr_seq_nbr :> varchar(8)

And CAST and CONVERT are basically the same.


#5

OK got it … Thanks for you help