TSQL Str() Error converting data type varchar to float.

Found someone had made this mistake, beware when doing something like

str(@LOCNCODE)

where @LOCNCODE is a varchar

The function is defined as:

STR ( float_expression [ , length [ , decimal ] ] )

So the variable is getting converted to a float before it is then turned back into a character data type, problem in my case was that it had worked for years until LOCNCODE one day contained letters as well as numbers.

 

Add comment

Loading