-1

In SQL Server I am using the concat function to join two columns. One column is numeric. Because of that after concat, the output shows that number in scientific notation. Is there any way to avoid that scientific notation?

I tried

concat (convert (numbercolumn as varachar), text_column)

but I get an error

concat is not a recognized built in function name

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user2543622
  • 5,760
  • 25
  • 91
  • 159
  • 3
    Sample data and desired results would help. – Gordon Linoff Dec 17 '20 at 18:00
  • 1
    *"the output shows that number in scientific notation"* This implies your source column is a `float`/`real` which is a problem unto itself. – Thom A Dec 17 '20 at 18:03
  • `CONCAT` was added in SQL Server in SQL Server 2008. If you are getting the message *"concat is not a recognized built in function name."* then you are using a version that is end of life and you really need to get that upgrade sorted out. – Thom A Dec 17 '20 at 18:05

1 Answers1

2

First, you don't need to explicitly convert, so:

concat(numbercolumn, textcolumn)

If this still converts to exponential, then convert to a decimal first. I'm not sure what you want things to look like but something like:

concat(convert(decimal(38, 10), numbercolumn), textcolumn)

You can also use format() or str() to convert the value to a string.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786