Home > database >  SQL variable assignment, values have braces and single quotes, prompt syntax errors,
SQL variable assignment, values have braces and single quotes, prompt syntax errors,

Time:11-19

Declare @ QNN nvarchar (4000)
The set @ QNN='INSERT INTO HUAWEI (TMNO TM02) VALUES (' AA', '0')
INSERT INTO HUAWEI (TMNO, TM02) VALUES (' CA ', '0') INSERT INTO HUAWEI (TMNO TM02) VALUES (' DA ', '0') '

The exec [HUAWEI_INSERTbatch] @ insertbachsql=@ QNN


How to change, thank you

CodePudding user response:

 set @ QNN='INSERT INTO HUAWEI (TMNO TM02) VALUES (' AA', '0') 
INSERT INTO HUAWEI (TMNO, TM02) VALUES (' CA ', '0')
INSERT INTO HUAWEI (TMNO, TM02) VALUES (' DA ' ', '0') '

CodePudding user response:

SQL server has two escape characters:
'by default, is the border of the string, if the string contains', you must use two' 1 'is the escape character,
Another escape character is "
When SET QUOTED_IDENTIFIER OFF, "is a string boundary, in the string" must use two "said,