Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select and then update

Author  Topic 

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-05-19 : 10:08:16
I have a select statement

SELECT ORDHFILE.OABL, ORDTFILE.ODLOTSEQ, ORDHFILE.OACUSTPO, ORDHFILE.OABLDATE, ORDHFILE.OAREGN, ORDHFILE.OASHIPDTMM, ORDHFILE.OASHIPDTDD, ORDHFILE.OASHIPDTYY, ORDHFILE.OASHIPVIA, ORDHFILE.OAFOB, ORDHFILE.OAATTN, CUSTFIL2.COBILLNUM, CUSTFIL2.COCNTRY, ORDHFILE.OASFNAME, ORDHFILE.OASFAD1, ORDHFILE.OASFAD2, ORDHFILE.OASFCITY, ORDHFILE.OASFST, ORDHFILE.OASFZIP, ORDHFILE.OASFZIP2, ORDHFILE.OASTNAME, ORDHFILE.OASTAD1, ORDHFILE.OASTAD2, ORDHFILE.OASTCITY, ORDHFILE.OASTST, ORDHFILE.OASTZIP, ORDHFILE.OADESC1, ORDHFILE.OAOPID, ORDTFILE.ODPNUM, PRODFIL2.PUPNAME1, PRODFIL2.PUPNAME2, ORDTFILE.ODQORD, ORDTFILE.ODMEAS, ORDTFILE.ODUM, ORDTFILE.ODCSC, ORDREM.OCCPREM1, ORDREM.OCCPREM2, ORDREM.OCCPREM3, ORDREM.OCCPREM4, ORDREM.OCCPREM5, ORDREM.OCCPREM6, ORDREM.OCCPREM7, ORDREM.OCCPREM8, ORDREM.OCCPREM9, ORDREM.OCCPREM10, ORDREM.OCCPREM11, ORDREM.OCCPREM12
FROM B108FFCC.CHEMPAXSNF.CUSTFIL2 CUSTFIL2, B108FFCC.CHEMPAXSNF.ORDHFILE ORDHFILE, B108FFCC.CHEMPAXSNF.ORDTFILE ORDTFILE, B108FFCC.CHEMPAXSNF.PRODFIL2 PRODFIL2, B108FFCC.CHEMPAXSNF.ORDREM ORDREM
WHERE (((ORDHFILE.OAWHS)='19') AND ((CUSTFIL2.COCNUM)=(ORDHFILE.OACNUM)) AND ((ORDTFILE.ODBL)=(ORDHFILE.OABL)) AND ((PRODFIL2.PUPNUM)=(ORDTFILE.ODPNUM)) AND ((ORDREM.OCBL)=(ORDHFILE.OABL)) AND ((ORDREM.OCPNUM)=(ORDTFILE.ODPNUM)) AND ((ORDREM.OCMEAS)=(ORDTFILE.ODMEAS)))
ORDER BY ORDHFILE.OABL, ORDTFILE.ODLOTSEQ

It works fine. However the data is being duplicated every 15 minutes instead of updating the changes. I am getting the same information over and over again.

I'm using DTS SQL Server Enterprise Manager.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-19 : 10:14:05
WHERE {SomeDateTimeColumn} >= DATEADD(MINUTE, -15, GETDATE())



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-05-19 : 10:20:56
More help? I'm new at this, 1 week only, and I'm not sure what I'm doing. This statement will update with new information every 15 minutes? Where do I put the statement in my query?

Lisa Jefferson
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-19 : 10:38:18
quote:
Originally posted by l-jeff@excite.com

More help? I'm new at this, 1 week only, and I'm not sure what I'm doing. This statement will update with new information every 15 minutes? Where do I put the statement in my query?

Lisa Jefferson


Are you insert this data onto some table?Can you give more info and where & how you're using this query?
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-05-19 : 10:47:23
I have a as400 at main office, and sql 2000 at my office. I need to get information pertaining to orders placed at main office for us to complete. I want to get the information every 15 minutes from as400 and import into a table here on my sql server 2000. The query, posted above, works however I noticed that the information is being duplicated every 15 miuntes. I need it to update\replace the original order if main office has made a change in the same table.

Does that make sense?

Lisa Jefferson
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-19 : 10:56:02
quote:
Originally posted by l-jeff@excite.com

I have a as400 at main office, and sql 2000 at my office. I need to get information pertaining to orders placed at main office for us to complete. I want to get the information every 15 minutes from as400 and import into a table here on my sql server 2000. The query, posted above, works however I noticed that the information is being duplicated every 15 miuntes. I need it to update\replace the original order if main office has made a change in the same table.

Does that make sense?

Lisa Jefferson


Yup. can you post whats your destination table and its structure?
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-05-19 : 11:03:49
destination table is to the shipping database, tbl_Data_OpenOrders on my local sql server 2000



Lisa Jefferson
Go to Top of Page
   

- Advertisement -