Qt issues with temporary tables, QODBC/MS SQL Server
-
Hi folks,
I'm having an issue doing anything with temporary tables within MS SQL Server while connected from Qt (4.7.3).
Here is an example piece of code, assume I am already connected:
@
QString querystr = "SELECT * INTO #TBUL1 FROM RealTable;";
querystr += "SELECT * FROM #TBUL1";
model.setQuery(querystr, database);
@It will tell me that the query is active and be without query or model errors, but there will be no data coming back to examine in the model (I've also tried doing it with a bare QSqlQuery object as well, and have attempted executing those statements individually).
When I execute this code, I am watching inside MS SQL Server Management Studio and I can even see the temporary table being created 'dbo.#TBUL1___________________' inside 'tempdb' during the session, but I don't seem to be able to do anything to the table after that.
When executing these exact statements as an isolated Query within Management Studio, I get my expected result of the 1 row currently in RealTable.
For reference, I have had no issues querying actual tables.
Thank you for reading, and I would appreciate any help!
-
Thanks for the reply. It turns out I simply didn't do it properly beforehand, but making subsequent queries is a solution to manipulate temporary tables:
@
QString querystr = "SELECT * INTO #TBUL1 FROM RealTable;";
QString querystr2 = "SELECT * FROM #TBUL1;";
model.setQuery(querystr, database);
model.setQuery(querystr2, database);
@This actually does the trick.