Inserting an Identity field?

  •  

    I'm using this query to archive Event Data from an EVENTS Table older than two weeks as the source for a Transform Data Task in DTS . Here's the query.

    SELECT *

    FROM events

    WHERE DATEDIFF(DAY, EVENT_DATE, getdate()) > 14

    I want to insert these records into an identical archive table, but let the ID Column in the Archive table increment on its own. Is there a way to do this with a Data Transform task or do I need to use an INSERT Statement to do this and just leave the ID Column blank?

  • Put all the columns that you need to transfer in the insert and select list omitting the primary key.

    Insert into ArchiveTable (Col1, Col2, ColN)

    Select Col1, Col2, Coln From dbo.Events where DATEDIFF(DAY, EVENT_DATE, getdate()) > 14

  • Thanks for the reply. I found this other solution to my problem in case anyone else needs it.

    Pat

     

    http://www.sqldts.com/default.aspx?293,1

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply