You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.)
The text was updated successfully, but these errors were encountered:
I started SQLCMD. Then I entered:
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.)
The text was updated successfully, but these errors were encountered: