I've faced a very strange ODBC problem, might save some hours of others: Connect to your SQL server database via ODBC
db: first open odbc://myDB
insert db "select 3 * 5"
copy db
>> [[15]] ;this is ok
if you put some variable declarations in your SQL, then
insert db "declare @i int; set @i = 3; select 3 * 5"
copy db
>> Invalid Cursor State Error
And the solution of this stupid problem is to put "set nocount on"
insert db "set nocount on; declare @i int; set @i = 3; select 3 * 5"
copy db
>> [[15]]
This is because of, SQL server tries to return more than one result set if you use more than one select and/or set statement in your query.