denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 497 forks source link

Error reading data: mssql: Incorrect syntax near '('. #623

Closed xenon007 closed 3 years ago

xenon007 commented 3 years ago

Good day! Could you please help. Why i have an error when request is ok in other scripts and SSMS?

select p1.[NUMBER], isnull(p1.real_beginning,p1.[PLANNED_START]) as PLANNED_START, p1.[PLANNED_END], p1.[ASSIGNMENT], p1.[ASSIGNEE_NAME], p1.[BRIEF_DESCRIPTION], d1.DISPLAY_NAME as [LOGICAL_NAME], p1.[SUBCATEGORY], [OUR] = CASE WHEN d1.DISPLAY_NAME like 'DESKTOP.%' or d1.[DISPLAY_NAME] like 'SERVER.%' THEN 1 ELSE 0 END, [DISASTER] = CASE WHEN p1.[SUBCATEGORY] like 'Cat1' THEN 1 ELSE 0 END from archive.dbo.PROBSUMMARYM1 p1 left join archive.dbo.DEVICE2M1 d1 on p1.[LOGICAL_NAME]=d1.[LOGICAL_NAME] where CONVERT(DATE,p1.PLANNED_START) between CONVERT(DATE,GETDATE()) and CONVERT(DATE,GETDATE()+1) and p1.[SUBCATEGORY] like 'Cat2%' or CONVERT(DATE,p1.real_beginning) between CONVERT(DATE,GETDATE()) and CONVERT(DATE,GETDATE()+1) and p1.[SUBCATEGORY] like 'Cat1'

It's a bug or not?

denisenkom commented 3 years ago

Please include logs: https://github.com/denisenkom/go-mssqldb/wiki#reporting-bugs

kardianos commented 3 years ago

@xenon007 What is the name of the driver you are using? is it "mssql" or "sqlserver". If this is erroring, use "sqlserver".

xenon007 commented 3 years ago

Please close issue. We solved the problem by creating a view