microsoft / microsoft/vscode-mssql

[Bug]: false positive syntax error - Incorrect syntax near 'THROW'.

Open
#22,353 0 comments 4 reactions 1 assignee Claimed by @aasimkhan30 View on GitHub
Area - Language Service Bug User-filed
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

### Description

MSSQL extension incorrectly marks single THROW statement inside BEGIN-END block as syntax error:
`Incorrect syntax near 'THROW'. Expecting CONVERSATION, DIALOG, DISTRIBUTED, or TRANSACTION.`

There are some workarounds like putting semicolon before THROW or after BEGIN or avoid BEGIN-END block but those are all against our coding guidelines.

### Steps to Reproduce

1. Open editor
2. Paste this code:
```
IF 1 = 1
BEGIN
THROW 50001, 'Some nasty error occurred.', 1;
END;
```
3. The THROW statement gets underlined as syntax error but it is false positive. This syntax is fine.

Image

### Affected Area

- [ ] Connection dialog (SQL Server | Azure browse/Fabric browse)
- [x] Query editor
- [ ] Query results panel
- [ ] Object Explorer
- [ ] GitHub Copilot integration
- [ ] Preview/Edit data
- [ ] Table Designer
- [ ] Schema Designer
- [ ] Schema Compare
- [ ] Local SQL Server Container provisioning
- [ ] SQL database in Fabric provisioning
- [ ] DACPAC/BACPAC export/import
- [ ] SQL Database projects
- [ ] Query Plan Visualizer
- [ ] Other (please describe below)

### If you selected "Other", please describe the affected area

_No response_

### Environment Information

VSC Version: 1.125.0 (user setup)
MSSQL plugin: 1.43.0
OS: Windows_NT x64 10.0.26100 (Windows 11)
Connection: None

### Confirmation

- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.