Script to Generate and Populate Date Dimension Version 2: Adding Multiple Financial Years

Posted by on Dec 11, 2013 in ETL, T-SQL | One Comment

Almost a year ago I published first version of T-SQL script to generate and populate a general purpose date dimension here. Today I want to publish the second version of that date dimension which has some corrections (fiscal calendar calculation fixed), and additional attributes (such as current year, current month, and current day) Multiple countries ...

Read More

Lag and Lead Functions in SQL Server 2012

Posted by on Sep 10, 2013 in SQL Server, T-SQL | No Comments

SQL Server 2012 has a set of useful functions to work in T-SQL environment. Lead and Lag are one of the most useful functions introduced in 2012. Lag function helps to access values from previous records, and Lead function helps to access values from next records in the data set. structure of working with these ...

Read More

T-SQL Script to get row count of all tables in the database

Posted by on Aug 18, 2013 in SQL Server, T-SQL | No Comments

Today I’ve wrote a simple script to get number of records for all tables in a database and fetch those tables that contains at least one record. This picture shows an example of result set: Here is the script: declare @tempTable table(tablename varchar(max), rowscount int,processed bit) insert into @tempTable select TABLE_NAME,0,0 from INFORMATION_SCHEMA.TABLES where TABLE_CATALOG=‘DEMO’ ...

Read More

Script for Creating and Generating members for Date Dimensions: General Purpose

Posted by on Jan 9, 2013 in Business Intelligence, ETL, SQL Server, T-SQL | No Comments

Date Dimension can be found in every Data Warehouse, because Date dimension is one of the most important factors of each operational system that users like to view reports based on date dimension. So the importance and requirement to a date dimension persuade me to write a t-sql script to generate records for date dimension. ...

Read More

Capitalize Function (Version 2.0) – T-SQL

Posted by on Oct 28, 2012 in SQL Server, T-SQL | No Comments

Hi folks, I’ve changed the t-sql code for Capitalize function, the previous capitalize function worked only if there is one space between words, but this version works even if there be more than one space between words. with this version of Capitalize; you can run the function like this: select dbo.Capitalize(‘st    charles‘) and this ...

Read More