ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runnings SQL Queries from excel (https://www.excelbanter.com/excel-programming/341422-runnings-sql-queries-excel.html)

Mahesh

Runnings SQL Queries from excel
 
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

Mike Fogleman

Runnings SQL Queries from excel
 
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




John.Greenan

Runnings SQL Queries from excel
 
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





Mahesh

Runnings SQL Queries from excel
 
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





John.Greenan

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





All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com