Link to home
Start Free TrialLog in
Avatar of catprotection
catprotection

asked on

Mass update parts of dates in orders table

I need to update various dates in an orders table to make them logically consistent before we can upgrade the system to the new version, for example the membership card expiry date should be the anniversary of the date they joined. I think I can do this with a CURSOR and iterate through all records 'fixing' the dates - but there are many thousands of orders and my understanding of CURSORS is that they are very slow and use a lot of resources.

Is there another way to carry out this type of update?
Avatar of Thandava Vallepalli
Thandava Vallepalli
Flag of United States of America image



UPDATE <YOUR_TABLE>  SET EXPIRY_DATE = DATEADD( YEAR, 1, JOINED_DATE )


itsvtk
Hi,

You can use my above query to get your requirement done.... Here is the artical on Date Funtions...

http://www.databasejournal.com/features/mssql/article.php/3076421

itsvtk
Avatar of catprotection
catprotection

ASKER

itsvtk - that will set ALL dates to be an anniversary of the JOINED_DATE rather than on a row by row basis?

Each order has its own JOINED_DATE and EXPIRY_DATE and so i need to compare each entry to establish what the correct date should be for that order before setting the date based on it
My Query will set on row by row basis only.....

if you have any doubts, take a backup of your table and run my query and check the data....

itsvtk :)
ASKER CERTIFIED SOLUTION
Avatar of Thandava Vallepalli
Thandava Vallepalli
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial