Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Date Dimension

By Satish Jayanthi,

There are 3 sections in this script:
1) Create the Date Dimension table
2) Load Data for a specified date range. Supply start and end dates to the variables
@startDate and @EndDate.
3) Update the column "LastDayOfMonth", which I find very useful while doing data analysis.
I use a function called "fnGetLastDayOfMonth" to obtain the last day of a given month.
You need to run the script in the listed order.

Note that the last three columns prefixed with the word "Holiday" are not populated with this script. These fields can be populated at the beginning of each year as you go or you can bulk update with a pre-populated "Holiday" table. I hope you find this script handy.

Total article views: 4695 | Views in the last 30 days: 18
 
Related Articles
FORUM

Script task variable population

How to use a variable populated by a script task later in the data flow.

BLOG

Script to Populate Date Dimension, without Using a Cursor

Most of the scripts I've used to populate date dimension uses a cursor. Since data is loaded only on...

BLOG

Script to Populate Date Dimension, without Using a Cursor

Most of the scripts I’ve used to populate date dimension uses a cursor. Since data is loaded only on...

FORUM

Staging table population

Staging table population

SCRIPT

Date and Time dimension creation and population T-SQL

Dim_Date and Dim_Time. Date and Time dimensions. Creation, population with holidays, indexing and u...

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones