select into #temptable

Generic selectors
Exact matches only
Search title only
Search in content
Search in all posts
Search in pages
Answers
Questions
2.82K viewsDataLink
0

in a custom sql statement can a select into a temp table be used and if so what is the syntax

0

OK Thanks. I logged for future release consideration.

0

SELECT donation_amount
INTO [#DONATIONS_TEMP]
FROM [Donations_&_Others] AS [Donations_&_Others]
where condition1

select * from [#DONATIONS_TEMP] where condition2

the second select would run against a smaller data set.

I think this should be in a future release.

0

One thing that JTDS does seem to accept is the DECLARE temp table:

DECLARE @myTableVar TABLE
(id INT PRIMARY KEY,
name varchar(50),
datetimeCreated datetime)

Maybe that will be useful…

0

Hi Mike – thanks for calling in on this. I thought I would post on the forum for everyone to see.

My initial thoughts.

The # sign for the temporary table seems to confuse JTDS driver. If I do a similar query with the ODBC driver:

SELECT donation_amount
INTO [#DONATIONS_TEMP]
FROM [Donations_&_Others] AS [Donations_&_Others]

It seems to work… in that I get a message of “no result set was produced” which makes sense since all this statement does is produce a temporary table.

The problem however is that now you need to run a new query to get the information out of the temp table. The current datalink functionality will not support multiple embedded sql statements. This is something we can consider for a future release.