Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:55:34+00:00 2026-06-13T20:55:34+00:00

I am surprised! This statement below is valid in SQL SERVER : SELECT +’ABCDEF’

  • 0

I am surprised! This statement below is valid in SQL SERVER:

SELECT  +'ABCDEF'

Has SQL Server defined + as a Unary operator for string types?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:55:36+00:00Added an answer on June 13, 2026 at 8:55 pm

    Here is my own answer to this question (Please also see the update at the end):

    No, there isn’t such unary operator defined on the String expressions. It is possible that this is a bug.

    Explanation:

    The given statement is valid and it generates the below result:

    (No column name) 
    ----------------
    ABCDEF
    (1 row(s) affected)
    

    which is equivalent to doing the SELECT statement without using the + sign:

    SELECT  'ABCDEF'
    

    Being compiled without giving any errors, in fact being executed successfully, gives the impression that + is operating as a Unary operation on the given string. However, in the official T-SQL documentation, there is no mentioning of such an operator. In fact, in the section entitled “String Operators“, + appears in two String operations which are + (String Concatenation) and += (String Concatenation); but neither is a Unary operation. Also, in the section entitled “Unary Operators“, three operators have been introduced, only one of them being the + (Positive) operator. However, for this only one that seems to be relevant, it soon becomes clear that this operator, too, has nothing to do with non-numeric string values as the explanation for + (Positive) operator explicitly states that this operator is applicable only for numeric values: “Returns the value of a numeric expression (a unary operator)“.

    Perhaps, this operator is there to successfully accept those string values that are successfully evaluated as numbers such as the one that has been used here:

    SELECT  +'12345'+1
    

    When the above statement is executed, it generates a number in the output which is the sum of both the given string evaluated as a number and the numberic value added to it, which is 1 here but it could obviously be any other amount:

    (No column name) 
    ----------------
    12346
    (1 row(s) affected)
    

    However, I doubt this explanation is the correct as it raises to below questions:

    Firstly, if we accept that this explanation is true, then we can conclude that expressions such +'12345' are evaluated to numbers. If so, then why is it that these numbers can appear in the string related functions such as DATALENGTH, LEN, etc. You could see a statement such as this:

      SELECT  DATALENGTH(+'12345')
    

    is quite valid and it results the below:

     (No column name) 
    ----------------
    5
    (1 row(s) affected)
    

    which means +'12345' is being evaluated as a string not a number. How this can be explained?

    Secondly, while similar statements with - operator, such as this:

     `SELECT  -'ABCDE'` 
    

    or even this:

    `SELECT  -'12345'` 
    

    generate the below error:

    Invalid operator for data type. Operator equals minus, type equals varchar.
    

    Why, shouldn’t it generate an error for similar cases when + operator has been wrongly used with a non-numeric string value?

    So, these two questions prevent me from accepting the explanation that this is the same + (unary) operator that has been introduced in the documentation for numeric values. As there is no other mentioning of it anywhere else, it could be that it is deliberately added to the language. May be a bug.

    The problem looks to be more severe when we see no error is generated for statements such as this one either:

    SELECT ++++++++'ABCDE'
    

    I do not know if there are any other programming languages out there which accept these sort of statements. But if there are, it would be nice to know for what purpose(s) they use a + (unary) operator applied to a string. I cannot imagine any usage!

    UPDATE

    Here it says this has been a bug in earlier versions but it won’t be fixed because of backward compatibility:

    After some investigation, this behavior is by design since + is an unary operator. So the parser accepts “+ , and the ‘+’ is simply ignored in this case.
    Changing this behavior has lot of backward compatibility implications so we don’t intend to change it & the fix will introduce unnecessary changes for application code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was surprised to find that Go has a 'goto' statement. I've always been
I was surprised when I run two statement in MySQL SELECT * FROM jobs
What is the statement below doing anyway? It's confusing to me. I am surprised
I'm surprised this doesn't happen automatically, but I would like my applications window to
I'm very surprised this issue hasn't been discussed in-depth: This article tells us how
Surprised that i havent been able to find this myself, but anyway. Let's say
I'm surprised I can't find this through googling, but I have a Viewbox in
I'm surprised I can't find a clear answer to this. So, in jQuery, you
Does anyone know how to do this? I am really surprised at the scarce
I was surprised, if I noticed it right, that $this->Js->object() autosorts the array i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.