Insert a crosstab to temp table

I

inungh

I would like to build my SQL to insert my crosstab query in to temp
table my SQL would like following:


INSERT INTO tblTemp
(Field1, Field2, Filed3.....)
SELECT DISCTINCT CField1, CField2, CField3....
FROM MyCrosstab WHERE MyField = [MyParam]


I can get Field1, Field2, Field3 and CField1, CField2, CField3 names,
but table name is a crosstab query.

Are there any way to build the SQL statement using code without using
a crosstab query for the table name?


Your information is great appreciated,
 
M

Michel Walsh

SELECT DISTINCT * INTO tempTable FROM crosstabQuery



will create the appropriate temp table (it must not exist, already)





Vanderghast, Access MVP
 
I

inungh

SELECT DISTINCT * INTO tempTable FROM crosstabQuery

will create the appropriate temp table (it must not exist, already)

Vanderghast, Access MVP




I would like to build my SQL to insert my crosstab query in to temp
table my SQL would like following:
INSERT INTO tblTemp
(Field1, Field2, Filed3.....)
SELECT DISCTINCT CField1, CField2, CField3....
FROM MyCrosstab WHERE MyField = [MyParam]
I can get Field1, Field2, Field3 and CField1, CField2, CField3 names,
but table name is a crosstab query.
Are there any way to build the SQL statement using code without using
a crosstab query for the table name?
Your information is great appreciated,- Hide quoted text -

- Show quoted text -

Do you mean that I have to use SELECT INTO, but not INSERT INTO?
Thanks again,
 
M

Michel Walsh

Select into creates the table to fit your need. You *can* use an Insert Into
***if*** the columns match in names (and type), by NOT specifying the
columns:


INSERT INTO temp SELECT * FROM crosstab


But if the names differ, that won't work. That is why the SELECT INTO is
'safer'.



Vanderghast, Access MVP


SELECT DISTINCT * INTO tempTable FROM crosstabQuery

will create the appropriate temp table (it must not exist, already)

Vanderghast, Access MVP




I would like to build my SQL to insert my crosstab query in to temp
table my SQL would like following:
INSERT INTO tblTemp
(Field1, Field2, Filed3.....)
SELECT DISCTINCT CField1, CField2, CField3....
FROM MyCrosstab WHERE MyField = [MyParam]
I can get Field1, Field2, Field3 and CField1, CField2, CField3 names,
but table name is a crosstab query.
Are there any way to build the SQL statement using code without using
a crosstab query for the table name?
Your information is great appreciated,- Hide quoted text -

- Show quoted text -

Do you mean that I have to use SELECT INTO, but not INSERT INTO?
Thanks again,
 
I

inungh

Select into creates the table to fit your need. You *can* use an Insert Into
***if*** the columns match in names (and type), by NOT specifying the
columns:

INSERT INTO temp SELECT * FROM crosstab

But if the names differ, that won't work. That is why the SELECT INTO is
'safer'.

Vanderghast, Access MVP


SELECT DISTINCT * INTO tempTable FROM crosstabQuery
will create the appropriate temp table (it must not exist, already)
Vanderghast, Access MVP
news:902b9308-123b-4a22-a84b-88f91395f8eb@r13g2000vbr.googlegroups.com....
I would like to build my SQL to insert my crosstab query in to temp
table my SQL would like following:
INSERT INTO tblTemp
(Field1, Field2, Filed3.....)
SELECT DISCTINCT CField1, CField2, CField3....
FROM MyCrosstab WHERE MyField = [MyParam]
I can get Field1, Field2, Field3 and CField1, CField2, CField3 names,
but table name is a crosstab query.
Are there any way to build the SQL statement using code without using
a crosstab query for the table name?
Your information is great appreciated,- Hide quoted text -
- Show quoted text -

Do you mean that I have to use SELECT INTO, but not INSERT INTO?
Thanks again,- Hide quoted text -

- Show quoted text -

Thanks again,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top