Link to home
Start Free TrialLog in
Avatar of Tyecom
TyecomFlag for United States of America

asked on

SQL Script Question

I created a SSIS package that will update certain tables every year.  Prior to updating these tables I want to run the "execute sql script" to change the current year to the next year automatically.  For instance, I want to 2011 to 2012.  I know I can update a column like...

update tablename
set columnname = 2012
where columnname = 2011

But I want to have this done automatically at the beginning of my SSIS package and not for just this year, but years to come, without having to worry about it.  Is there a sql script that would perform this.  Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
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

would't be better to have COMPUTED column in these tables?

like...

CREATE TABLE #test (
      i int IDENTITY(1, 1),
      actualYear AS DATEPART(YY, GETDATE())
)

or, is it really necessary to have some column like that in a table at all???
What's the meaning of that column?? Which way do you use it in queries ??

Avatar of Tyecom

ASKER

Thank you both for responding.  MWVISA1 your approach seems to be what I want, I will be testing it and will get back to you.  jvejskrab, it is necessary to have these column, they are  part of a larger scope.  The SSIS package will be ran once a year at the end of each year.  The tables will be updated with the current data and the year column needs to be updated to the next fiscal year.  Again, I'm just trying to automate this entire process.  It used to be done manually.
Avatar of Tyecom

ASKER

Mwvisa1 your approach worked great.  Thank you very much.  I chose the first option and it worked just like I wanted it to.  Thanks again!
Avatar of Tyecom

ASKER

Worked great!  Thank you very much!
You are most welcome. Good luck!
Best regards and happy coding,

Kevin