Single-quote concatenation string in SQL Server (Error writing error "Floating-point value XXXX exceeds the computer representation range (8 bytes). There is a syntax error near "XX". ")

Source: Internet
Author: User

The use of " ' " (single quotation marks): In SQL Server, two " ' " (single quotation marks) in the case of stitching strings, that is, the concatenation of a " ' " single quote string.

The correct wording is given in this column:

 set   @sql  =    update #temp_monthKQ_Users Set Day    +   @curruntCount  +    =   +   @descTemp  +    where user_id =   +   @user_id  +    

The error is spelled as follows:

Set @sql = 'Update #temp_monthKQ_Users set Day'+@curruntCount+'=" "+@descTemp+" "WHERE user_id =" "+@user_id+";
There are 2 fewer quotes behind the variable @user_id, so there is a "'" (single quotation mark) to the far right of the string after print (@sql), so it is necessary to add 2 "'" (single quotes) in order to not lose the stitching "'" single quotation mark.

After executing the @sql, the error is as follows:

If a variable with a varchar type (here is @user_id) does not add a single quotation mark (and the SQL Server identifies the @user_id as a floating-point number, restricts 8 bytes and truncates the field to a 8-bit string ):

Set @sql = ' Update #temp_monthKQ_Users set Day ' + @curruntCount + ' = " " + @descTemp + " "  '+@user_id+;

As follows: bc460011 is the truncated string, @user_id variable at the moment the value is: 4028e5855335612201533573bc460011.

Is the correct wording:

Single-quote concatenation string in SQL Server (Error writing error "Floating-point value XXXX exceeds the computer representation range (8 bytes). There is a syntax error near "XX". ")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.