what's wrong with this query
CREATE TABLE TABLE2 AS SELECT * FROM TABLE1
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David SmithPosted Oct 11, 2010, 10:07 AM
to explain in example what im doing:
im basically running a query for table 1 to populate a status column via the query below, then i grab the calculated status column and select into table2, after I select into table 2, i then call the Select query ( SELECT * into newTable FROM table2) in c# code, after running the query, i go back to the database and the table is empty. the weird thing is it works perfect in the actual database
SELECT middle.datetime, middle.serialnum, Min(middle.pass) AS status
FROM (SELECT [middle].ID, [middle].Maxoftestnames, [middle].datetime, [middle].serialnum, [middle].tag, [middle].count, [middle].threshold, IIf(count<=threshold,'PASS','FAIL') AS pass FROM (SELECT Datatable1.ID, Max(Datatable1.ID) AS ID, Max(Datatable1.TestNames) AS MaxOftestnames, Max(Datatable1.stamp) AS datetime, Max(uutserialnum) AS serialnum, Datatable1.tag, Count(Datatable1.tag) AS count, table_Threshold.Threshold FROM Datatable1 LEFT JOIN table_Threshold ON (Datatable1.tag=table_Threshold.tag) AND (Datatable1.ID=table_Threshold.ID) GROUP BY Datatable1.ID, Datatable1.stamp, Datatable1.tag, table_Threshold.Threshold) AS middle WHERE ((([middle].tag) Like '[123456789ABCD]*'))) AS middle
GROUP BY middle.datetime, middle.serialnum
ORDER BY middle.datetime;
Posted Oct 11, 2010, 6:25 AM
This link may help you.
Posted Oct 11, 2010, 6:24 AM
SELECT INTO Table2 FROM Table1;