Valid SQL using temp tables returning no result set <p>I've been searching google and stack overflow for the past several hours, and can't seem to find an exact match on this issue. I'm relatively new to java, so please correct me if I'm just doing something incredibly silly!</p> <p>Issue: When executing a try-with-resource query (statement.executeQuery(stmt)) I am getting a 'Statement did not return a result set'</p> <p>I can guarantee this is valid SQL, and when run through SSMS the query works - and when using the select...into...from style syntax, this query works as well [in java]. The select...into...from is not a viable option though as it creates performance issues (23 second query turns into a 5+ minute query due to resource utilization)</p> <p>Proof of concept: SQL file: c:\test.sql</p> <pre><code>set nocount on create table #test (loannum int) insert into #test (loannum) select 1 select * from #test drop table #test </code></pre> <p>This query is used to make a cached result set so that I can pass the data around other functions without leaving an open connection to the database...</p> <p><strong>Note: SQLInfo in the below is just "C:\test.sql"</strong> &lt; snip></p> <pre><code>try(BufferedReader in = new BufferedReader(new FileReader(SQLInfo))) { String str; StringBuffer sb = new StringBuffer(); while((str = in.readLine()) != null) { sb.append(str + System.getProperty("line.separator")); } _stmt = sb.toString(); } </code></pre> <p>&lt; /snip></p> <p>which is later used in the below... &lt; snip></p> <pre><code>try (Connection connection = DriverManager.getConnection(CONNECTION); Statement statement = connection.createStatement(); ResultSet resultset = statement.executeQuery(_stmt) ) { crs.populate(resultset); return crs; } catch (SQLException e) { e.printStackTrace(); } return crs; </code></pre> <p>&lt; /snip></p> <p>What I'm expecting, is a cached result set that will be used in a defaulttablemodel to display a "loannum" field, and value of 1 -- what I really get is the following error: "com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set..."</p> <p>If I modify the SQL to the following:</p> <pre><code>set nocount on select 1 as loannum into #test select * from #test drop table #test </code></pre> <p>I get the expected return result of "loannum" with value of 1.</p> <p>It appears to have something to do with the create table statement in the executeQuery method, but it's a temporary table! Is there any way to make the above to work with the create table (value type, value type, value type) insert into... method?</p> <p>**Note: I've attempted to use the .execute(String) method, and parse through the return results. It appears to have the same issue, but it's entirely possible I'm implementing it incorrectly.</p> <p>**Secondary note: The defaulttablemodel works fine, and returns information to a JTable that displays on screen. This dynamically allocates the column names, and displays the associated values. I can provide a sample of this code if needed, but i don't think it's relevant to the issue as this is failing on simply creating the resultset, rather then when it's trying to assign the information to the table model.</p> <p>[Editing this in]: Stored procedures on SQL side are not a viable option in this instance. This is a query against a data warehouse that does not allow stored procs as company policy (I've pushed back, and have been smacked down) - As a result, I'm working on this ... hackish solution.</p> <p>Hopefully somebody has some insight into this issue!</p>