0

I have this SQL Server query that causes this error

Incorrect syntax near ')'

in my Windows Forms application written in C#.

I think this can cause in different way and I'm stuck at it finding where that syntax error is. It seems the error is around:

datetime2) >= CAST("12/30/1996 12:00:00 AM" as datetime2) and upper(status

Here's my full query

select * 
from 
    (select 
         PMSEQ, SWERK, EQUNR,
         MPTYPE, DATE, TIME,
         RECDC, IDIFF, READR,
         IIND, QMART 
     from 
         P_PM_TBLIF240 
     where 
         cast(concat(concat(date, ' '), time) as datetime2) >= cast('12/30/1996 12:00:00 AM' as datetime2) 
         and upper(status) = 'ACTIVE') a  
where 
    PMSEQ not in ()

Hope someone help to get out here

Thank you in advance

1
  • 2
    Please do not add unnecessary tags. This doesn't have anything to do with C#, let alone a WinForms user interface. Commented Jan 8, 2020 at 2:55

1 Answer 1

2

The problem is that not in () is empty.

Run the scipt below:

select * from (select PMSEQ,SWERK,EQUNR,MPTYPE,DATE,TIME,RECDC,IDIFF,READR,IIND,QMART from P_PM_TBLIF240 where CAST(concat(concat(date,' '), time) as datetime2) >= CAST('12/30/1996 12:00:00 AM' as datetime2) and upper(status) = 'ACTIVE') a  where PMSEQ not in ('1')

Because I dont have the data, I am going with the guess that PMSEQ is text. Let me know

Sign up to request clarification or add additional context in comments.

3 Comments

i think that you can put an empty in not in() base on w3school sql syntax tutorial
@Berzerk25: I think your understanding is wrong. An empty set makes no sense in SQL. Quoting w3school as an authority is useless. Try the SQL Server Books on Line (Google it), which is the official documentation for SQL Server.
yes your answer is correct,. thank you for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.