Generally Qlikview is great at processing scripts copied and pasted directly from T-SQL. So a SELECT * FROM x WHERE .... type script works perfectly fine, even if it is quite complex (lots of inner and outer joins, CASE WHEN statements, etc etc).
However, I've run into a problem where the SQL script relies on a temporary disk table. The following script format is running okay (i.e. Qlikview reports no errors and returns back to the application when it has finished and displays the Select Fields box). But no data is returned.
SQL SELECT * INTO #temp FROM dbo.x SELECT a, b, SUM(c), COUNT(d) FROM #temp GROUP BY a, b DROP #temp;
Could someone tell me what I am doing wrong and how I can fix this? In the above simple example, I need the data from SELECT a, b, SUM(c), COUNT(d) FROM #temp GROUP BY a, b to be returned into the table QlikviewTable. Running the script on my SQL Server gives exactly this.
By using resident I was able to solve my immediate problem.
I'm still not sure this would work if the second chunk of SQL code was particularly complex (because essentially the first bit is SQL, the second is a LOAD statement in a QV script). In this case, I would have to use a stored procedure as Clever Anjos suggested.
A SP would have been the easiest thing to do - if only the IT department allowed me to create my own SPs and Views!! Right now I don't have access to do this, but fortunately, that's going to change soon.