Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create table

9 views
Skip to first unread message

Doug Howell

unread,
Mar 28, 2013, 12:58:40 PM3/28/13
to
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

unread,
Mar 28, 2013, 2:40:53 PM3/28/13
to
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)
0 new messages