huafist opened a new issue, #31913:
URL: https://github.com/apache/superset/issues/31913
### Bug description
SuperSet v4.1.1, MSSQL Server.
I have a query that starts with a DECLARE Statement:
DECLARE
@StartDate SMALLDATETIME,
@EndDate SMALLDATETIME
SELECT @StartDate = '20241201',
@EndDate = '20241231',
IF OBJECT_ID('tempdb..#Temp') IS NOT NULL
DROP TABLE #Temp
IF OBJECT_ID('temdb..#Temp2') IS NOT NULL
DROP TABLE #Temp2
....
In this order, the query runs in SQL Lab, but if I try to create a chart or
save the dataset, I get the following error:
(156, b"Incorrect syntax near the keyword 'DECLARE'.DB-Lib error message
20018,....)
Alternatively, if I move the DECLARE and SELECT statements below "DROP TABLE
#Temp2", the query again runs, but if I try to create a chart, I get the error:
Error parsing near 'OBJECT_ID' at line 4:12
### Screenshots/recordings
_No response_
### Superset version
4.1.1
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [ ] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]