Dbeaver with sql server how to set multiple variables in one run?

11.6k views Asked by At
@set test10 = 5
select ${test10}

if i run this in dbeaver it gives me 5. However if i change to 7 it does not work if i select both lines together. Is that some kind of joke?

I did also read about changing Dbeaver settings: dbeaver settings for parameters

Which is actually set as above screenshot.

as mentioned by larnu i changed the query to following:

DECLARE @test1 int, @test2 int;
SET @test1 = 11;
SET @test2 = 22;
SELECT @test1, @test2;

which is now prompting a window every time i run the query: enter image description here

What am I missing here?

Same behavior if i want to define 2 variables at the top of the query:

@set test10 = 7
@set test11 = 8
select ${test10}, ${test11}

It does only work if i run line 1 then line 2 where after i can finally see the changes made by running line 3.

I was only finding split parts of explanations in the documentation and on Stack overflow so far

1

There are 1 answers

0
Baffioso On BEST ANSWER

Use Execute SQL Script (Alt+X) command to process multiple statements.

@set test1 = 'Foo' 
@set test2 = 'Bar'
select :test1, :test2

Explained here: https://github.com/dbeaver/dbeaver/issues/2244#issuecomment-333441954