variable declaration with cte
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
I'm having trouble declaring a variable and a cte in one statement. This is something that works with `sqlcmd`.
Statement
```
STMT=$(cat <<'EOF'
DECLARE @bar INT = 1
;with foo as (select @bar as foo)
select * from foo
GO
EOF
)
```
sqlcmd
```
$ sqlcmd -S sqlserver.corp.com -U username -P password -Q "${STMT}"
foo
-----------
1
(1 rows affected)
```
mssql-cli
```
$ mssql-cli --username username --password password --server sqlserver.corp.com --query "${STMT}"
Commands completed successfully.
Msg 137, Level 15, State 2, Line 2
Must declare the scalar variable "@bar".
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the provided DECLARE, CTE, and GO statement through mssql-cli, then inspect the query execution and batch handling entry points. Compare the behavior with sqlcmd; done means the same statement executes without the scalar-variable error and returns the expected row.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100