Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect syntax near ';'. error on valid DECLARE statement in SQL Server 2019 #32330

Open
ray-kudos opened this issue May 13, 2024 · 4 comments
Labels

Comments

@ray-kudos
Copy link

Description

I tried to run a query below, but encountered an error in DBeaver stating "Incorrect syntax near ';'. " when executed, even though it runs okay in SSMS.
BEGIN
DECLARE @error1 INT = CASE WHEN 1 = 1 THEN 1 ELSE 0 END;
SELECT @error1;
END
image

DBeaver Version

Community Edition Version 24.0.4.202405051837

Operating System

Windows 10 Pro 20H2

Database and driver

  1. MSSQL Server 2019
  2. MS SQL Server / SQL Server

image

Steps to reproduce

  1. Open the master database on MSSQL Server 2019.
  2. Execute scripts below.
    BEGIN
    DECLARE @error1 INT = CASE WHEN 1 = 1 THEN 1 ELSE 0 END;
    SELECT @error1;
    END

Additional context

No response

@E1izabeth
Copy link
Member

Thank you for bug report. As a workaround, you can select whole block and press Execute SQL query.
image

@E1izabeth E1izabeth added xf:sql execution Queries execution and removed wait for review labels May 13, 2024
@ray-kudos
Copy link
Author

Thank you for the workaround. It worked for those scripts. However, when I executed the actual scripts below using your workaround, I encountered an "Incorrect syntax near 'GO'." error and if I executed the scripts using Execute SQL Scripts (Alt+X), I received an "Incorrect syntax near ';'." error.

IF OBJECT_ID ( '[dbo].[temp_procedure]', 'P' ) IS NOT NULL
DROP PROCEDURE [dbo].[temp_procedure];
GO
CREATE PROCEDURE [dbo].[temp_procedure]
@ChildDBName NVARCHAR(128),
@ParentDBName NVARCHAR(128)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @TableSuffix NVARCHAR(128) = CASE WHEN COALESCE(@ParentDBName, '') = '' THEN '' ELSE @ChildDBName END;
END

@E1izabeth
Copy link
Member

You can change statement delimiter from ; to GO in preferences
image

@ray-kudos
Copy link
Author

I have done it but it still shows the same errors.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants