joeyslaptop
New Member
- Joined
- Aug 26, 2011
- Messages
- 27
I have a query that does the following:
This Executes in SQL Server, and in the Microsoft Query Editor window when I go to edit it. But when I run it via a Refresh in Excel, the status says that the query is running, and then it just ends without returning my results. I can post the whole query but would rather not if I don't have to.
Any ideas on what I'm doing wrong?
Drops Table #Temp if it exists
Creates a new temporary table called #Temp (which I have in other queries that work)
Declares some variables
Sets a loop-count variable (by counting the rows of the Table Schema).
WHILE the @NumberofLoops <= my loop count variable
BEGIN
SET some variable values via a query of the schema table
BEGIN
EXEC ('Select * into #Temp ([column name],[columnName2]) SELECT * FROM ('+ @variables + 'some other stuff)')
END
SET the @NumberOfLoops to @NumberOfLoops +1
END the loop
SELECT * FROM #Temp
Creates a new temporary table called #Temp (which I have in other queries that work)
Declares some variables
Sets a loop-count variable (by counting the rows of the Table Schema).
WHILE the @NumberofLoops <= my loop count variable
BEGIN
SET some variable values via a query of the schema table
BEGIN
EXEC ('Select * into #Temp ([column name],[columnName2]) SELECT * FROM ('+ @variables + 'some other stuff)')
END
SET the @NumberOfLoops to @NumberOfLoops +1
END the loop
SELECT * FROM #Temp
This Executes in SQL Server, and in the Microsoft Query Editor window when I go to edit it. But when I run it via a Refresh in Excel, the status says that the query is running, and then it just ends without returning my results. I can post the whole query but would rather not if I don't have to.
Any ideas on what I'm doing wrong?