Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: 4924 | Views in the last 30 days: 3
 
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...

BLOG

T-SQL script to find the highly populated tables in database

Sometimes we need to check which tables of our database is highly populated. Below is the T-SQL Scri...

FORUM

Staging table population

Staging table population

Tags
 
Contribute