|Message:||Unclosed quotation mark before the character string ‘%.*ls’.|
|This error occurs when a Transact-SQL statement contains mismatched single or double quotes. The SET QUOTED_IDENTIFIER setting will determine which combinations of single and double quotations marks are valid. For more information about SET QUOTED_IDENTIFIER, see “SET QUOTED_IDENTIFIER” in Books Online.
Each single or double quotation mark used to mark the beginning of a literal string must have a corresponding quotation mark of the same type to mark the end of the literal string. A single quotation mark cannot be paired with a double quotation mark to delimit a single literal string.
Quotation marks that are part of the literal string are handled differently. If a single quotation mark (‘) is part of the literal string, it can be represented by two single quotation marks (”). If a literal string is delimited by double quotation marks and SET QUOTED_IDENTIFIER is OFF, the string can contain embedded single quotation marks, such as apostrophes. If a literal string is delimited by single quotation marks and SET QUOTED_IDENTIFIER is either ON or OFF, the string can contain embedded double quotation marks.
If you do not place the correct type and number of quotation marks in each place in your code, SQL Server will return the above error, possibly along with an “Incorrect syntax near %” error.
For examples of quotation mark usage, see “SET QUOTED_IDENTIFIER” in Books Online.