Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Patyk
Yak Posting Veteran
74 Posts |
Posted - 2014-01-07 : 14:43:01
|
I need to create a store procedure to open a table containingFiscal Year, Fiscal Month, Start Date, End Date, Number of Weeks, calculate number of weeks and insert this number into Number Of Weeks column?All is populated except the number of weeksThanks |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-01-07 : 15:16:52
|
first thought is use date datediff function:DATEDIFF(week, [Start Date], [End Date])A general principal is not to store a value that can be derived from other values in the same row. In other words can you just use this function whenever you want to see the value and not store it in the table? An alternative is to define the column as a "computed column" using that function as its definition.Be One with the OptimizerTG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-08 : 05:52:24
|
quote: Originally posted by Patyk I need to create a store procedure to open a table containingFiscal Year, Fiscal Month, Start Date, End Date, Number of Weeks, calculate number of weeks and insert this number into Number Of Weeks column?All is populated except the number of weeksThanks
what according to you represents a week? does it coincide with iso week?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|