• Your string literal need to be NVarchar, not Varchar.

    @query shouldn't be in quotes, you want the executesql to execute the contents of that variable, not to try and execute the literal '@query', which will just give you a syntax error. You had it right in the original code.

    The third parameter for sp_execute_sql is also incorrectly formed, go back and check the examples in the page I linked.

    The value for @Query is just 'ISNULL(cast( ExtTotalExperienceUS as nvarchar) + ',' , '') + ISNULL(cast( ExtRelevantExperienceUS as nvarchar) + ',' , '') + ISNULL(cast( ExtSSNNumber as nvarchar) + ',' , '') from HC_RESUME_BANK where RID = 31418', which I'm sure you can see will throw a syntax error when run, as there's no SELECT and in addition you need to add @Query2 into that dynamic SQL to get the value assigned.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass