Thanks for your response, Permual. I think you might have the solution, but I'm not sure I undserstand exactly. Could I ask you to modify the code snippet below to show me exactly how you think your solution should work?
Here's the code:
Set datefirst 1;
With MyCTE as
from orders..ordertable (nolock)
I know this may be a little late, but I found your question when I ran into a similar issue. Here is the result I used:
In Qlikview Script ...
set vSQL = "DECLARE @SQL VARCHAR(500)
SET @SQL = '
USE [BI-Transform]' + CHAR(59) + '
WITH myCTE AS (
SELECT TOP 10 * FROM dbo.tblVariables)
SELECT * FROM mycte' + CHAR(59)