title: Temporory tables using Spring's jdbc template
body: <p>I'm facing an issue executing a very long query using spring jdbcTemplate. The query contains multiple <code>DECLARE</code> statements, multiple <code>CREATE</code> temp tables and in the end a <code>SELECT</code> statement which gets data by joining multiple tables as well as <code>DROP</code> statements. When I run this query directly in SQL Management studio, the query runs perfectly fine and returns me the data. However when I run the exact same query using spring's jdbc template there is no data returned.</p>
  
  <p>Edit: I can not post exact query I'm using. But below is the template of how the query may look. </p>
  
  <pre><code>public class SpringJdbcExample{
  
          public static final String sql = "DECLARE "+
          "@XYZ DATETIME='1/31/2016', " +
          "@ABC UNIQUEIDENTIFIER='', " +
          "@var1 VARCHAR (1)='F', " +
          "@var2 UNIQUEIDENTIFIER = NULL " +
  
  
          "DECLARE @id1 INT, @id2 INT, @id3 Int "+
          "SELECT @id1=(SELECT id1 FROM table1 WHERE XYZ=@XYZ) "+
          "SELECT @id2=(SELECT id2 FROM table2 WHERE ABC=@ABC) " +
  
              "SET NOCOUNT ON "+
              "SET TRANSACTION ISOLATION LEVEL    READ UNCOMMITTED "+
  
  
              "CREATE TABLE #temp1 (var1 INT, var2 INT, var2 INT, var4 varchar(20) ) "+
  
              "CREATE TABLE #temp2 (var1 INT,var2 INT, var3 DATETIME, var4 varchar(20)) "+
  
          -- More Create temp tables
  
          -- Insert into temp tables from various DB tables
  
      -- single Select statement from temp tables
  
      -- Drop temp tables
      "; // end of the string
  
      private JdbcTemplate jdbcTemplate;
  
      public SpringJdbcExample (JdbcTemplate jdbcTemplate){
        this.jdbcTemplate = jdbcTemplate;
      }
  
      public List&lt;String&gt; getData(){
      // MapSqlParameterSource
      MapSqlParameterSource params = new MapSqlParameterSource("someParams", "someValues");
      jdbcTemplate.query(sql,params);
      }
  </code></pre>