We are using DBeaver Community Edition (v23.2.0.202309041200) as a client connecting to Microsoft SQL Server 2016 (v13.0.5101.9).
The issue happens when executing the below SQL statements in DBeaver as a script.
declare @option as int = 2;
select @option;
The action "Execute SQL script", or by DBeaver hot key Alt+X
, always fails on the selecting statement, with error message saying SQL Error [137] [S0002]: Must declare the scalar variable "@option".
.
The error does not happen if we highlight the two SQL statements and go with action "Execute SQL query", or by DBeaver hot key Ctrl+Enter
.
The error does not happen either if we use Microsoft SQL Server Management Studio, so we do not believe the issue is related to SQL Server.
Our Question:
Is there any way we can use declared variables in DBeaver when executing a SQL script on MSSQL (Microsoft SQL Server)?
We highly appreciate any hints and suggestions.
;
from the first line, such that it's written asdeclare @option as int = 2
, does the script work withALT + X
?