dbcli / dbcli/mssql-cli

variable declaration with cte

Open
#447 1 comment 1 reaction 0 assignees View on GitHub
bug
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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.