0

I have numbers and i want to convert those number into string in the stored procedure.

Please reply.

Thanks !

pankaj Vagare
  • 93
  • 1
  • 1
  • 7

2 Answers2

12

Without knowing what database you're using, we cannot give an exact syntax. Here's the syntax for MSSQL:

CAST(column AS VARCHAR(10))

Or

CONVERT(VARCHAR(10), column)
negacao
  • 1,244
  • 8
  • 17
  • For me CONVERT(VARCHAR(10), column) worked but I needed to use VARCHAR(50) as I am dealing with international telephones with many formats. – Aggie Jon of 87 Jan 25 '22 at 18:04
1

A conversion in T-SQL can be done with the CAST function. A sample can be:

SELECT CAST(myNumber AS VARCHAR) FROM myTable

where myNumber is your numeric field, and myTable the table in which the field is present. A cast can be used as a parameter for joins too.

Another function you can use is STR:

SELECT STR(myField) FROM myTable
hypnos
  • 369
  • 1
  • 10