2

I am trying to run a basic T-SQL script

    DECLARE @temptable TABLE(
      abilityTypeId BIGINT NOT NULL,
      companyId BIGINT NOT NULL
    );

    INSERT INTO @temptable(abilityTypeId, companyId)
    VALUES (1, 2);

    SELECT * FROM @temptable;

but I get the following error:

SQL Error [1087] [S0002]: Must declare the table variable "@temptable". Must declare the table variable "@temptable".

MERGE INTO is also not working. Is it possible to get this working on Linux or do I have to use Visual Studio for this?

3
  • 4
    This works fine in SSMS, so I'd imagine DBeaver does some weird parsing. This would likely be better as a support question to the vendor. Jul 11, 2019 at 14:05
  • I thought this is related to SQL engine, so maybe I just didn't figure out how to select the right one. Still, basic SQL and listing tables does work properly (MSSQL database in docker) Jul 11, 2019 at 14:09
  • Yep, you should talk to DBeaver about that. Sounds like you've got a lot going on over there. Jul 11, 2019 at 14:13

1 Answer 1

5

DBeaver parses queries one by one using a statement delimiter (“;” by default) and executes them consecutively.

Try removing the empty lines and those “;”.

Check more details here.

2
  • 1
    THANKS! I CAN'T BELIEVE THIS WAS THE PROBLEM! Jul 11, 2019 at 14:24
  • 3 years later, this still happens and is hard to find in a sea of "Remove the GO statement" answers that aren't applicable when you have no GO statements. This is what fixed it for me. Great find!
    – oooyaya
    Mar 23, 2022 at 16:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.