Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

Default Dimension Members Generator (T-SQL)

5.00/5 (1 vote)
22 Aug 2016CPOL1 min read 9.6K   52  
T-SQL script which generates and executes INSERT statements for missing default dimension members (Unknown, Not Available, Not Applicable)

Introduction

Someone deleted those default dimension members from Data Warehouse (again)? Nothing to worry about - using T-SQL script provided (needs user input), you can generate those members in no time.

Background

Properly designed dimensions in data warehouses always have one or more default members, such as 'Unknown', 'Not Available' and 'Not Applicable':

  • Unknown member is used when we receive a valid piece of information from the source system (not null) which cannot be matched with any of the existing business key attributes in a dimension.
  • Not Available member is used when we receive "empty" information from the source system (NULL)
  • Not Applicable member is used when certain attribute does not apply to certain record in Fact table.

More about default members can be found here.

Using the Code

The code provided in the attachment can be used in both Microsoft SQL Server and Azure SQL Data Warehouse BI solutions. The code should be pretty straightforward with only several places where adequate textual values specific to your needs should be entered. Those places in code are marked with 'USER_INPUT'.

For the convenience, the first variable in the script @IsDebug can be set to 'Y' during the test phase. Setting it to 'N' will actually execute generated code.

History

  • 2016-08-23: Initial code version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)