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

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

Date Dimensions in T-SQL using CTE

By Bhudev Prakash,

As several blogs/links are available for getting Time Dimension Scripts e.g.:

  • http://www.sqlserver007.com/2010/01/20/sql-server-date-and-time-dimensions-in-t-sql-using-cte/
  • http://consultingblogs.emc.com/jamiethomson/archive/2007/01/11/T_2D00_SQL_3A00_-Generate-a-list-of-dates.aspx
  • http://www.dataprix.com/en/blogs/carlos/time-dimension-structure-and-load-script-sqlserver
  • http://www.sqlservercentral.com/scripts/Data+Warehousing/65762/

I required new Time Dimension script as I required little more information for Semister, Quater, Month,ForthNight, Week etc. Folloings are steps to create & populate data into Time Dimension table:

  1. To Create DimTime Table execute Script 1
  2. By Default it will populate data between 01-01-2010 and 31-12-2020 dates. If anybody wants to change date range please set date values for parameters @StartDate & @EndDate.
  3. To Populate Data into DimTime table execute Script 2

 

Total article views: 3458 | Views in the last 30 days: 11
 
Related Articles
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

sql script to populate time dimension

Incremental script for the time dimension

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...

FORUM

generating or populating time dimensions

generating or populating time dimensions in sql

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