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

SQLCMD must stay connected #68

Closed
sommarskog opened this issue Apr 3, 2022 · 1 comment · Fixed by #71
Closed

SQLCMD must stay connected #68

sommarskog opened this issue Apr 3, 2022 · 1 comment · Fixed by #71
Assignees

Comments

@sommarskog
Copy link

I started SQLCMD. Then I entered:

1> USE Northwind
2> go
Changed database context to 'Northwind'.
1> SELECT * FROM "Order Details"
2> go
Msg 208, Level 16, State 1, Server SOMMERWALD, Line 1
Invalid object name 'Order Details'.

And I thought "What?".

Profiler revealed what is going on. For every batch you are connecting and disconnecting. So for the SELECT statement I was back in my default database.

That does not fly. SQLCMD is like SSMS. Once, I have connected, I should stay connected. The above is only one example of what goes wrong. I may create a temp table which I want to use in the next batch. This fails. I may start a transaction that I want to run over multiple batches. But that transaction is rolled back with the first batch. (Which means that only the rest of the transaction is performed, which is really bad.)

(To be precise, SSMS has an option that permits you to disconnect on every query. But that is not a default setting.)

@shueybubbles shueybubbles added this to To do in Sqlcmd Version 1.0.0 via automation Apr 4, 2022
@shueybubbles shueybubbles added this to the Public Preview milestone Apr 4, 2022
@shueybubbles
Copy link
Collaborator

The Go sql/driver model doesn't optimize for long lived connections, but it should be doable.

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

Successfully merging a pull request may close this issue.

2 participants