Author |
Topic |
jylland
Starting Member
27 Posts |
Posted - 2013-01-07 : 09:19:55
|
hiI want to make loop but how to do ?I have a test database with two tables Look1 and Look2, andI want to move data from Look2 to Look1 and with weeks implementedLook2 tableId date1 12-30-20122 12-31-20133 01-01-20134 01-02-20135 01-03-20136 01-04-20137 01-05-20138 01-06-20139 01-07-201310 01-08-201311 01-09-2013moreLook1 as it should look likeId date weeknumber1 12-30-2012 532 12-31-2012 13 01-01-2013 14 01-02-2013 15 01-03-2013 16 01-04-2013 17 01-05-2013 18 01-06-2013 19 01-07-2013 210 01-08-2013 2more |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2013-01-07 : 09:27:26
|
How are you defining the week number?Years usually end with week 53==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
jylland
Starting Member
27 Posts |
Posted - 2013-01-07 : 09:38:43
|
thanks I forgot 53 weeks in a yearAbout the defining week number thats one of theproblems for me how to do ? maybe isn't a loop I need ?quote: Originally posted by nigelrivett How are you defining the week number?Years usually end with week 53==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-07 : 10:15:14
|
does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
jylland
Starting Member
27 Posts |
Posted - 2013-01-07 : 12:30:57
|
yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2013-01-07 : 12:34:50
|
will datepart(wk,date) do?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-07 : 23:32:19
|
quote: Originally posted by jylland yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry but your modified output looks like you just want weeknumber returned by datepart. then wats the issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
jylland
Starting Member
27 Posts |
Posted - 2013-01-08 : 05:19:31
|
yes that could be a solution or sum from a specific date and + one week up every 7 days, so the week number is 60 after 5 years.quote: Originally posted by visakh16
quote: Originally posted by jylland yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry but your modified output looks like you just want weeknumber returned by datepart. then wats the issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-08 : 05:37:47
|
quote: Originally posted by jylland yes that could be a solution or sum from a specific date and + one week up every 7 days, so the week number is 60 after 5 years.quote: Originally posted by visakh16
quote: Originally posted by jylland yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry but your modified output looks like you just want weeknumber returned by datepart. then wats the issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
nope weeknumber returned by DATEPART will reset after every 53 weeks------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
jylland
Starting Member
27 Posts |
Posted - 2013-01-08 : 09:16:33
|
yes how I make jobagent which every week take dates from look2 table and put it to look1 table and put weeknumber in !quote: Originally posted by visakh16
quote: Originally posted by jylland yes that could be a solution or sum from a specific date and + one week up every 7 days, so the week number is 60 after 5 years.quote: Originally posted by visakh16
quote: Originally posted by jylland yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry but your modified output looks like you just want weeknumber returned by datepart. then wats the issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
nope weeknumber returned by DATEPART will reset after every 53 weeks------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-08 : 23:52:36
|
quote: Originally posted by jylland yes how I make jobagent which every week take dates from look2 table and put it to look1 table and put weeknumber in !quote: Originally posted by visakh16
quote: Originally posted by jylland yes that could be a solution or sum from a specific date and + one week up every 7 days, so the week number is 60 after 5 years.quote: Originally posted by visakh16
quote: Originally posted by jylland yes that's the meaningquote: Originally posted by visakh16 does that mean you need week number to restart after 52?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry but your modified output looks like you just want weeknumber returned by datepart. then wats the issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
nope weeknumber returned by DATEPART will reset after every 53 weeks------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
for copying from one table to other useINSERT look2SELECT...FROM look1WHERE...what should be values generated for weeknumber?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2013-01-09 : 22:03:13
|
Are you, perhaps, looking for the ISO Week number?--Jeff Moden RBAR is pronounced "ree-bar" and is a "Modenism" for "Row By Agonizing Row".First step towards the paradigm shift of writing Set Based code:"Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column." When writing schedules, keep the following in mind:"If you want it real bad, that's the way you'll likely get it." |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-10 : 23:03:01
|
quote: Why you reply with quote non-stop?This is not good for other people that want to read the topic...
I didnt explicitly quote earlier posts. i just replied to last post from OP which had all the other conversation------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|