Need help with store proc.....that great

  • Hi,

    I need to write a store proc to move the data from table1 to table2. Both tables are in different databases on same server . When data is moving from table1 to table2. I t should satisfy with the condition.

    What the condition is, the data which is in table1 should not cross 3 months. That mean the row or record which inserted today should move to table2 after 3 months. The columns in table1 are creation date, archive_date, archive_id and so on..... Take creation_date to check with condition. Creation_date mean row inserted date.

    I need just logic. If anyone help with this logic that would be great.

  • without the ddl it is difficult to provide exact code, but something like

    Insert into table2 (col1,col2 etc..)

    select col1,col2 from table1

    where createdate < dateadd(mm,-3,getdate())

  • Please don't double-post. You asked the same question in multiple forums, and there's no need to do that. It just fragments the answers and discussion.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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