Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible? 1

Status
Not open for further replies.

aspx

Programmer
Jul 25, 2002
52
BG
Hi!
I have table with 2 fields:
f1 - varchar(50), f2 - datetime (actually dd.mm.yyyy - dd='01' - always).

Now some data:
Name1 - 01.03.1999,
Name2 - 01.06.1999,
Name1 - 01.07.2000,
Name3 - 01.09.2000 and so on...

Is it possible to write such a StoredProcedure which:
1. Copy records where f2 like '2000' and
2. Insert again these records, but with changed year (in f2) - to be '2003'.
For example the above table after inserting will be:
Name1 - 01.03.1999,
Name2 - 01.06.1999,
Name1 - 01.07.2000,
Name3 - 01.09.2000,
Name1 - 01.07.2003,
Name3 - 01.09.2003
.

Problem is that there are more than 200 000 records and use Access to copy the data in one table, then I run update query and I then insert these records in the old table...
 
Is F2 truely datetime? If so try this:

insert into table
select f1, dateadd(yy,+1,f2) from table where year(f2) = 2000

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top