DBeaver does not recognize declared variable when executing SQL script on SQL Server
2
votes
2
answers
6696
views
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 [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.
Asked by James
(149 rep)
Oct 3, 2023, 11:11 PM
Last activity: Nov 23, 2023, 08:22 PM
Last activity: Nov 23, 2023, 08:22 PM