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.
| Author |
Topic |
|
Kevin Driscoll
Starting Member
2 Posts |
Posted - 2005-04-28 : 20:23:55
|
| First timer here..Was wondering if anyone could help me with a problem.I have a table of "Historical" general ledger records 3.5 million records.I have another table that pulls this months current fiscal period records.I want to be able to automate the inclusion of this months records into the historic table.This data is pulled nightly so the records may already be in the historical table.Would like to use a DTS package.Any ideas? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-28 : 20:29:05
|
Not sure why you'd want to use DTS for this.INSERT INTO DestinationTable (ColumnList)SELECT ColumnListFROM SourceTableWHERE PKColumn NOT IN (SELECT PKColumn FROM DestinationTable)Example:DECLARE @Source table (Column1 int, Column2 varchar(50))DECLARE @Dest table (Column1 int, Column2 varchar(50))INSERT INTO @Source VALUES(1, 'Tara')INSERT INTO @Source VALUES(2, 'Mike')INSERT INTO @Source VALUES(3, 'Alex')INSERT INTO @Source VALUES(4, 'Rebecca')INSERT INTO @Source VALUES(5, 'Zach')INSERT INTO @Dest VALUES(1, 'Tara')INSERT INTO @Dest VALUES(2, 'Mike')SELECT * FROM @SourceSELECT * FROM @DestINSERT INTO @Dest (Column1, Column2)SELECT Column1, Column2FROM @SourceWHERE Column1 NOT IN (SELECT Column1 FROM @Dest)SELECT * FROM @Dest Tara |
 |
|
|
Kevin Driscoll
Starting Member
2 Posts |
Posted - 2005-04-29 : 07:08:24
|
I thought I could schedule this to happen every morning with a DTS,will this work?like this?INSERT INTO GL_TRANS_HIST (GLTRANS, DOCNO, LINE, ANNOTATION, ACCTNO, WONO, TYPE, TRANSNO, DEB_AMT, CRED_AMT, ENTRY_DATE, JOBNO, DEB_HRS, CRED_HRS, LABGRADE, CRTNO, FISPER)SELECT GL_TRANS, DOCNO, LINE, ANNOTATION, ACCTNO, WONO, TYPE, TRANSNO, DEB_AMT, CRED_AMT, ENTRY_DATE, JOBNO, DEB_HRS, CRED_HRS, LABGRADE, CRTNO, FISPERFROM GL_TRANSWHERE GL_TRANS NOT IN (SELECT GLTRANS FROM GL_TRANS_HIST)quote: Originally posted by Kevin Driscoll First timer here..Was wondering if anyone could help me with a problem.I have a table of "Historical" general ledger records 3.5 million records.I have another table that pulls this months current fiscal period records.I want to be able to automate the inclusion of this months records into the historic table.This data is pulled nightly so the records may already be in the historical table.Would like to use a DTS package.Any ideas?
|
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-04-29 : 07:26:36
|
| Why do you want to use a dts package (which means a client application).==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-29 : 12:33:08
|
| Just put the code into a job. You don't need DTS for this at all. It would add extra overhead to it and it just isn't needed.Tara |
 |
|
|
|
|
|
|
|