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 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: 3643 | Views in the last 30 days: 5
 
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