View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John.Greenan John.Greenan is offline
external usenet poster
 
Posts: 175
Default Runnings SQL Queries from excel

Ok, so try calling the table ##table....

Where you run the code from is not relevant - in vb or query analyser. The
session is still there.

--
www.alignment-systems.com


"Mahesh" wrote:

Hi John,
I want to run the queries in the same session. Problem here is i am
not running the queries in the SQL Analyzer. i am running it through excel
using some macros.
E.g: I place a query in one cell and the macro will run the query to
populate the results in new sheet.
so when i give select * from customer it gives the data output
but when i give select * into #temp1 from customer and then run another
query select * from #temp1 it gives an error saying invalid object #temp1.

Can you please help how to get rid of this error and populate the data from
#temp1

Thanks,
Mahesh


"John.Greenan" wrote:

Do you create the temporary table within the same SQL session/connection?
The temporary table is normally only session specific. You could try
creating the temp table as a global temp table - call it ##name rather than
#name



--
www.alignment-systems.com


"Mike Fogleman" wrote:

In my experience you cannot run a new query in the same range as a previous
query. Only a refresh is allowed of the previous query. Either delete the
range of the previous query or use a different, non-overlapping range.
Mike F
"Mahesh" wrote in message
...
Hi,
I am running SQL queries from excel and populate the sheets. I have a
problem when i am running the queries which create temp tables. After i
create temp table and run another query on that temp table (#temp1) it is
giving an error.

Can any one help on this