Unclosed quotation mark before the character string ‘%.*ls’.

Details
Product: SQL Server
Event ID: 105
Source: MSSQLServer
Version: 8.0
Component: SQL Engine
Message: Unclosed quotation mark before the character string ‘%.*ls’.
   
Explanation
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 more information about managing quotation marks in code, see these Microsoft Knowledge Base articles:
311023 and 311021.

For examples of quotation mark usage, see “SET QUOTED_IDENTIFIER” in Books Online.

   
User Action
  • Check whether QUOTED_IDENTIFIER is true for your current session with this Transact-SQL command:
    SELECT SESSIONPROPERTY(‘QUOTED_IDENTIFIER’)
    Depending on your needs, you may need to change the setting with SET QUOTED_IDENTIFIER ON/OFF.
  • Verify that each quotation mark intended to delimit a string has a matching quotation mark of the same type.
  • Verify that each quotation mark that is part of the literal string is represented by two of the same type of quotation mark.

Related:

Leave a Reply