Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Generate Months from unique records with...
15 posts, Page 2 of 2
««
1
2
Generate Months from unique records with different date ranges
Rate Topic
Display Mode
Topic Options
Author
Message
Jason-299789
Jason-299789
Posted Tuesday, January 08, 2013 12:18 AM
SSC Eights!
Group: General Forum Members
Last Login: Today @ 10:57 AM
Points: 838,
Visits: 2,200
Nice Alternative dwain, love the use of cross applys with the tally and inline month generator, as well as the normalisation of the month to always be the first.
_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1403993
dwain.c
dwain.c
Posted Tuesday, January 08, 2013 12:22 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 1:40 PM
Points: 2,370,
Visits: 3,251
Jason-299789 (1/8/2013)
Nice Alternative dwain, love the use of cross applys with the tally and inline month generator, as well as the normalisation of the month to always be the first.
Thank you sir!
For some reason, I get a lot of pushback around here when I suggest using an actual Calendar table and I'm not sure why. I've even developed a nifty GenerateCalendar FUNCTION (that Jeff Moden took pity on and improved to warp speed) to take its place. Thought that was a bit much to post on this question although the technique is not dissimilar.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1403995
Jason-299789
Jason-299789
Posted Tuesday, January 08, 2013 12:44 AM
SSC Eights!
Group: General Forum Members
Last Login: Today @ 10:57 AM
Points: 838,
Visits: 2,200
Id love to see the GenerateCalendar function.
Coming from a DW background the persisted calendar table is second nature, and I'm surprised more traditional OLTP systems dont implement one as part of a standard build as its very low maintenance.
At worst you might have to extend it and put in any regional public holiday's and business specific information (financial periods etc) as part of a once a year maintenance routine.
_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1404004
dwain.c
dwain.c
Posted Tuesday, January 08, 2013 12:54 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 1:40 PM
Points: 2,370,
Visits: 3,251
Jason-299789 (1/8/2013)
Id love to see the GenerateCalendar function.
Coming from a DW background the persisted calendar table is second nature, and I'm surprised more traditional OLTP systems dont implement one as part of a standard build as its very low maintenance.
At worst you might have to extend it and put in any regional public holiday's and business specific information (financial periods etc) as part of a once a year maintenance routine.
PM'd you with the FUNCTION.
I think most of the push back I get is because of a lack of understanding. I meant, by the way, here at work and not on the forums where Calendar tables are well established.
I like to keep holidays in a separate table that can be joined on the Calendar table when needed. The Calendar table is then like, set it and forget it. Only the holidays table then needs maintenance annually. And can also then be country or state/province specific.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1404010
Kyalo
Kyalo
Posted Monday, February 11, 2013 5:49 PM
Forum Newbie
Group: General Forum Members
Last Login: Monday, April 01, 2013 5:12 PM
Points: 4,
Visits: 17
Thank you Dwain, this works like Magic and I don't have to create a calendar....much appreciated
Post #1418702
« Prev Topic
|
Next Topic »
15 posts, Page 2 of 2
««
1
2
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.