Search code examples
sql-servert-sqlconcatenationnvarchar

What is the difference between + and ++ when concatenating nvarchar?


I just saw sql code which concats 2 strings with '++'. I always use single plus like '+'

what is the point of using '++'

 PRINT 'TEST ' ++ 'TEST'

Solution

  • PRINT 'TEST ' ++++++++++++ 'TEST'  
    

    or

    PRINT 5+++++++++++++++++++++2
    

    Still works because, "Although a unary plus can appear before any numeric expression, it performs no operation on the value returned from the expression. "

    Look into below documentation: https://msdn.microsoft.com/en-us/library/ms174362.aspx