Discussion:
Create table
(too old to reply)
Doug Howell
2013-03-28 16:58:40 UTC
Permalink
I have a query that returns values I want. I'd like to have that query create/overwrite a database table every 15 minutes. The tables' data should be completely overwritten every time it runs. How would I go about doing this? Here's the query:

Select IZPN,CMDESC,USRN34
from AS400.S102BAFE.AADAT10.DE100M
Where USRN34 <> 0;
Bob Barrows
2013-03-28 18:40:53 UTC
Permalink
Post by Doug Howell
I have a query that returns values I want. I'd like to have that
query create/overwrite a database table every 15 minutes. The
tables' data should be completely overwritten every time it runs.
Select IZPN,CMDESC,USRN34
from AS400.S102BAFE.AADAT10.DE100M
Where USRN34 <> 0;
I assume you need to do this because this query takes a while to run?

To initially create the table:
Select IZPN,CMDESC,USRN34
INTO newtable
from AS400.S102BAFE.AADAT10.DE100M
Where USRN34 <> 0;

Add or set the primary key on the table using the table designer in SSMS.

Now that the table is created, use:

truncate table newtable;
INSERT newtable (IZPN,CMDESC,USRN34)
Select IZPN,CMDESC,USRN34
from AS400.S102BAFE.AADAT10.DE100M
Where USRN34 <> 0;

Continue reading on narkive:
Loading...