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". ")