syntax error Unclosed quotation mark after the character string

ahmed salah 3,216 Reputation points
2021-06-02T09:52:01.44+00:00

I work on sql server 2012 i face syntax error when run query below

SELECT  PartID,Code,Co.CodeTypeID,Co.RevisionID,Co.ZPLID,Count(1) as ConCount
                FROM 
                [ExtractReports].dbo.PartAttributes PM 
                INNER JOIN  [ExtractReports].dbo.Condition Co ON Co.ZfeatureKey = PM.ZfeatureKey Where (1=1 and   (PM.ZfeatureKey= 1506990046 And Name ='Aluminum') Or (PM.ZfeatureKey= 1506990006 And Name ='Unthreaded') Or (PM.ZfeatureKey= 1506990016 And Name Not In('#4-40','#6-32','#1-64','#1-72','#8-32','#10-32','#2-56','#2-64','#3-48','#4-36','#3-56','#4-48','#6-40','#0-80','#5-40','#10-24','#12-24','#2-28','#4-20','#8','#4','#6','#2','#10','#14','#10-16','#2-32','#0.25-20','#8-18','#12-14','#4-4','#6-13',') ) Group By PartID,Code,Co.CodeTypeID,Co.RevisionID,Co.ZPLID  Having Count(1)>= 3

so after un query above
i get these syntax error
so how to solve this issue and why this error done

Msg 105, Level 15, State 1, Line 4
Unclosed quotation mark after the character string ') ) Group By PartID,Code,Co.CodeTypeID,Co.RevisionID,Co.ZPLID Having Count(1)>= 3
'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ') ) Group By PartID,Code,Co.CodeTypeID,Co.RevisionID,Co.ZPLID Having Count(1)>= 3

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,705 questions
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 46,551 Reputation points
    2021-06-02T10:43:43.457+00:00

    12-14','#4-4','#6-13',') ) Group

    Here it is; in IN clause ends with a comma + a single apostrophe, without a closing apostrophe.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.