How to concatenate a string that looks like a number?

  • This is the first line in my query...
    select '1002.' + b.dept_20K + '.90003' as 'roc',

    but I get an error "Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value '1002.' to data type int."
    I tried a few different ways to convert to varchar but, still getting the error. Any thoughts?

  • NineIron - Thursday, January 19, 2017 11:44 AM

    This is the first line in my query...
    select '1002.' + b.dept_20K + '.90003' as 'roc',

    but I get an error "Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value '1002.' to data type int."
    I tried a few different ways to convert to varchar but, still getting the error. Any thoughts?

    Use the convert function to typecast b.dept_20K to a character string.

    😎

  • Eirikur Eiriksson - Thursday, January 19, 2017 11:49 AM

    NineIron - Thursday, January 19, 2017 11:44 AM

    This is the first line in my query...
    select '1002.' + b.dept_20K + '.90003' as 'roc',

    but I get an error "Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value '1002.' to data type int."
    I tried a few different ways to convert to varchar but, still getting the error. Any thoughts?

    Use the convert function to typecast b.dept_20K to a character string.

    😎

    Thanx. I was trying to convert the '1002.'. Rookie mistake!

  • This was removed by the editor as SPAM

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply