Live! 360–Speaking at SQL Server Live Orlando 2016

If you are looking for a great conference to attend, please look at Live! 360. This event combines 6 different areas of IT (including SQL Server) with some of the great experts presenting sessions for 5 days. The sessions are on December 5th thru the 9th in Orlando, FL at Royal Pacific Resort.

This is a link with a discount code for up to $500 dollars off –

Here are the three I am giving.

SQT07 New Performance Tuning and Security Features in SQL Server 2016


2:00pm – 3:15pm

Level: Introductory to Intermediate

SQL Server 2016 has added and improved features to an already great product. To start, there is now a Query Store to retrieve history of a query’s execution plan and statistics used for that plan. You can compare them to see the changes. You can also see the Execution Plans “Live” to see where a long running query is spending lots of time. You can also compare plans side-by-side, which should make DBAs or anyone that performance tune queries very happy.

From there, you’ll go into some of the database design aspects of 2016 to improve table implementation. In-Memory has been half-baked in previous versions and now is enterprise ready with OLTP tables. The Column-store indexes include update-able clustered and non-clustered indexes. Temporal Tables remove the requirement of using triggers or custom code to find a point in time version of the data. You now can mask columns for limited viewing and casting of data to the end users by login permissions.

The T-SQL enhancements will help with better writing of set-based queries. The stretch database feature will assist in archiving data to the cloud with access in applications. Always Encrypted secures the database for abiding to regulations in health care and finance. The last feature will be row-level security, which has been a frequently requested option.

You will learn:

  • About T-SQL enhancements in SQL Server 2016
  • About Table design changes in SQL Server 2016
  • About Query Plan improvements in SQL Server 2016


SQW05 Master Data Management with Data Quality (DQS) and Master Data Services (MDS) in SQL Server 2016


9:30am – 10:45am

Level: Intermediate

Is there data scattered all over your enterprise? Has your boss asked you to help your users create and manage one source of common data? Are there different spellings of values in the same column of a table? Can you use help from algorithms to find the best match? Is the Customer or Product table in multiple databases with different columns? Do you need help managing the Data Warehouse?

This session will jump into SQL Server 2016 with DQS and MDS. You use the Data Quality projects in Integration Services (SSIS) to rank values and help with misspelled data. You’ll help your users manage the DQS projects giving them management access to data quality and moving that responsibility to the business where it should be.

Next, you’ll use MDS to help consolidate dimensions scattered in multiple databases to form a true Conformed Dimension area. MDS will help your company move away from spreadsheets or flat files to manage critical information for analytics. These features were added to SQL Server in version 2012 and have been upgraded in 2014 and 2016 to help enterprises with the task of Master Data Management.

You will learn:

  • How to use Data Quality Services to cleanse data with DQS and SSIS
  • How to create a Master Data Management system with MDS in SQL Server 2016 to consolidate multiple data sources


SQW12 Improve Enterprise Reporting with SQL Server Analysis Services


4:00pm – 5:15pm

Level: Intermediate

Have you been at a job where requests keep coming in for more and more reports? Does it seem like some are being used and other are not? Are some of the reports exactly the same except a different grouping or sorting request? Has your boss asked you to investigate a Business Intelligence or Data Warehouse solution? Well, it might be time to start using SQL Server 2016 Analysis Services.

Dimensional Modeling is one of the best starts for designing a system with flexible reporting. The database model fits perfectly into Analysis Service (SSAS) databases from Microsoft. There will be a use case for 3 fact tables to create various data marts. We will demonstrate a Multidimensional Cube and the Tabular Model to help you make the decision of which installation to use. Excel and PowerBI will be the focus for reporting.

Using a Lookup Component in SSIS for Surrogate Keys in a Fact table

There are many suggestions for loading a data warehouse using SQL Server integration Services (SSIS). Once you get started, you find a pattern to repeat for facts and dimensions. This might be because the consistency Dimensional Modeling suggests for the design of fact and dimension tables. The SSIS Lookup component provides options to divert handling of non-conformed data or you can use your T-SQL skills up front where a diversion is not necessary.

The most common use of a Lookup component is to find the Dimension surrogate key for one or more rows in a fact table. The CustomerKey from the Customer dimension will be used in the Sales Fact table in order to join to customer hierarchies and attributes like the following T-SQL:


SELECT c.CommuteDistance, Sum([OrderQuantity]) AS OrdQty , Sum([SalesAmount]) AS SalesAmt

FROM [dbo].[FactInternetSales] fis

INNER JOIN dbo.DimCustomer c ON c.CustomerKey = fis.CustomerKey

GROUP BY c.CommuteDistance





5-10 Miles



2-5 Miles



1-2 Miles



0-1 Miles



10+ Miles



Table 1: Sales Amount and Order Qty sums for Commute Distance


Once you get the source data for the Sales fact in an SSIS package, the Lookup component can be used to get the surrogate from the customer dimension. In Figure 1, the object LU – Customer Key lookup in the flow of populating this fact table.



Figure 1: Loading the FactInternetSales table from the AdventureWorksDW Database


The options for Lookups vary based on some properties. In Figure 2, we can see some of these options.



Figure 2: General Lookup properties


Most lookups for dimensions can use the Full Cache mode because there is not a lot of dimension rows. But, if you come across large dimensions in a data warehouse, sometime should be spent seeing if a Partial Cache or No Cache will help with loading speed as well as using a Cache connection manager. The Full Cache option will load all the data from the dimension table into memory before any flow starts in the package. This is why it is good not to SELECT all the columns in the dimension table for a lookup.



Figure 3: Connection properties


Figure 3 shows the connection using a T-SQL statement to only get the CustomerKey and CustomerAlternateKey from the DimCustomer table. The CustomerAlternateKey is the business key that matches customer to rows in the source data for FactInternetSales. If you use the option “Use a table or a view”, the generated query will select all columns from the source.

Let’s go back to the General properties to look at “Specify how to handle rows with no matching entries”. Figure 4 shows the different options available.



Figure 4: General properties


The “Fail component” option will stop processing of the import if no match is found in the lookup table. This is not a good option for loading data into a fact table. Most systems would want the import to continue for the customer surrogate keys that are found.

  1. Ignore Failure – Null will replace lookup values selected. Those rows with no match are streamed to the normal flow in package with the Null value in match columns selected.
  2. Redirect rows to error output – red line output will show a failure but can pipe the data to any component. Those rows with no match are not streamed to the normal flow in package.
  3. Fail component – the package stops with a failure if no match exists, if all match there is no failure
  4. Redirect rows to no match output – output can be piped to another component and processing continues. Those rows with no match are not streamed to the normal flow in package.

So, the two other options I use most are “Redirect rows to no match output” or “Ignore Failure”. The redirect rows… option can be used to stage the rows that have problems and get someone to look at them before the next import. The Ignore Failure option can be used to substitute a Null value in the CustomerKey column.

Now, this will not work if importing to a fact table with foreign keys and a Not Null property on the CustomerKey column, but what I do most often is change the Null value to -1 and have an entry in the DimCustomer table for the Unknown possibility like this example.


















Figure 5: Derived Column component


Figure 5 shows what can been done to convert the Null value in the CustomerKey column to -1. This way with the -1 row in the customer dimension table, we will be able to insert the row into the fact table without having to process the rows outside of this package.



Figure 6: Selected Lookup Columns and names


Figure 6 shows the Columns tab Properties. Here is where we match the Source fact column for customer to the Business Key in the Customer Dimension. We also select the CustomerKey from the Available Lookup Columns list in order to get the surrogate key for the fact table. The selected CustomerKey is where the Null value will be located if no match if found.

This process also indicates that another process needs to be implement to determine why existing fact rows have business keys for the customer source table that are not imported into the Customer dimension. This one tip can go a long way and patterns developed to help with this situation. It also indicates the power and flexibility SSIS provides data warehouse architects in implementing an ETL solution for its business.

PASS Summit 2016 – Connect, Share, Learn

Please join me and about 4000+ other technology professionals for the annual PASS Summit in Seattle, WA October 24th – 28th. But before I talk about this year’s event, join me in a trip down memory lane about my path to the PASS Summit. If not, skip to the end of this blog. Smile


My first trip to the PASS Summit was in 2007 or 2008 in Denver, CO. I saw the advertisement on with names of speakers that had written articles I was familiar with. To think I would get to learn from these speakers and get out of the office for a week seemed only a dream. But, it became a reality. My boss actually wanted to attend as well which started a training fund for the IT department. had a code that would give you a discount for the event as well as entry to the then famous Reception Party and Casino Night with prizes. Man that used to be fun.


Opportunities at work guide us to the sessions to attend. First, we wanted to know more about clusters since we had two different physical clusters that had some problems with failing over and restarting. There were many databases to manage, but two in particular were 500+ GBs (on SQL Server 2005) and growing fast. A indexing and rebuild versus reorg session grab our attention. The last objective was to see what DataDude was all about. This was the first version of a database project in visual studio. I think Grant Fritchey did this talk. There was also a Database Normalization talk given by Louis Davidson and Paul Nielsen (really miss Paul’s talks at PASS).


Of course, since Microsoft was going to be present at the event, we had to spend time talking to the support team about problems with SQL Server. A vender, Scalability Experts, had a booth and two of the speakers had help us with an upgrade from SQL Server 2000 to 2005. Does anyone even remember those wonderful times?


After our second journey to the Summit the following year, I started thinking that I could do some of these talks because I had learned just as much as they were teaching. This started me on speaking at Lunch and Learns at work followed by the Baton Rouge SQL Server User Group (Thanks Patrick LeBlanc). I think I actually spoke at the .Net User Group first. I also started going into LSU with AITP to teach subjects about databases as well as career sessions to show graduates the different technology companies in and around Baton Rouge.


Since then, I have had the privilege to speak many times through the years on many topics I use day to day at work. Most tedious has been the volunteer work with the Abstract Review and PowerPoint Review committees over the past 6 years as well as helping the Performance, Data Architect and Excel BI Virtual Chapters. This has enable me to get out of my shell and interact with the larger Professional Association of SQL Server user community (oops! Now the Microsoft Data Technology community). Smile

This has led me to being selected this year to speak at the PASS Summit 2016 in Seattle, WA. I am really going to enjoy sharing the stage with Bill Anton for a SSAS Performance Improvement session. If you have not started reading Bill’s blog, please start. He is a smart dude with some great experience and enthusiasm with Analysis Services.

So, all this was given from me to you to invite you to the PASS Summit. It does not matter why you come: Sessions, SQLCAT, Networking, Speaking (future speaker), Vender parties, SQLKaraoke or just a break from work. Make the trip, get involved and help change or mold the Microsoft Data Technology community into what we need to help others adopt to the new features or tune the old skills.

Why use a Date Dimension Table in a Data Warehouse

In the Data Mart, or the Data Warehouse world, there is a date dimension table in all schemas if you are using the Kimball Dimensional Modeling method. In the beginning of Dimensional Modeling, it was called a Time dimension. Since then, the Time dimension has actually been separate from the date values. After listing all these terms: time, date, dimensional modeling, data mart, data warehouse, etc., you might be more confused than ever about what we are talking about.

So, let’s start with some definitions. A Data Mart is actually a small part of a Data Warehouse. The Data Warehouse is considered the entire set of tables in a database. The Data Mart is defined as a business process that is represented by the data contained in the process. The structure of a Data Mart is to enable a simplistic way to do querying or reporting. The data population stage has a component that translates the data complexity into an actual column for a description rather than a code.

Dimensional Modeling is the process to take the data from various sources and produce this Data Mart structure with usually one Fact table and multiple Dimension tables. The Dimension tables are related to the Fact table by a surrogate keys. The Fact contains the measures of the data the business process wants to consume. There can be multiple Data Marts in a Data Warehouse, so do not get hung up by the single Fact table in a Data Mart. Eventually, you will see the Dimension tables related to many Fact tables in the overall schema. These dimension are termed Conformed Dimensions.

The Date dimension is one of these dimension tables related to the Fact. Here is a simple Data Diagram for a Data Mart of Internet Sales information for the Adventure Works DW database which can be obtained for free from CodePlex or other online sources.


As you can see in this diagram, the Date table (DimDate) is related to the fact table (FactInternetSales) by 3 different dates in the fact: Order, Ship and Due Date. This is called a Role Playing dimension in the Dimensional Modeling world. The relationship is created by the surrogate keys columns (integer data type) rather than the date data type. The DateKey column in the DimDate table is related to the OrderDateKey column in the FactInternetSales table as well as ShipDateKey and DueDateKey.

The DimDate table has columns that normally would have to be extracted from a Date column with a function. These include CalendarYear, CalendarQuarter or DayNumberOfMonth. The data in this table has a row for every day possible in your Data Mart.

























































Think about the reason for every day to be in this table. If there are no Internet Sales on 12/28/2010, then we would have to do some fancy LEFT JOIN with a sub-query to create this row in an analysis of the data. But, with a Date Dimension table, we LEFT JOIN from the DimDate table to the Internet Sales fact table and we can extract $0 with a IsNull(SalesAmount) from this query.

SELECT d.CalendarYear, d.FullDateAlternateKey, Sum([SalesAmount])

  FROM dbo.DimDate d

    LEFT JOIN [dbo].[FactInternetSales] fs ON fs.OrderDateKey = d.DateKey

  WHERE d.CalendarYear = 2010

    AND d.MonthNumberOfYear = 12

  GROUP BY d.CalendarYear, d.FullDateAlternateKey

  ORDER BY d.CalendarYear, d.FullDateAlternateKey


The query users have to write against a Data Mart are much simpler than against a transaction database. There are less joins because of the one to many relationships between the fact dimension table(s). The dimension tables are confusing to someone who has been normalizing databases as a career. The dimension is a flattened or de-normalized table. This creates cases of duplicate data, but the simplistic query overrides the duplicate data in a dimensional model.

With this table, we can stop using functions on date columns like YEAR (), MONTH (), etc. So, a query from an OLTP might look like this:

SELECT DATEPART(Year, SOH.OrderDate), SUM(DET.LineTotal) AS Sales

  FROM Sales.SalesOrderHeader SOH

    INNER JOIN Sales.SalesOrderDetail DET ON SOH.SalesOrderID = DET.SalesOrderID


Whereas the dimensional model query would look like this:

SELECT d.CalendarYear, Sum(SalesAmount)

  FROM dbo.FactInternetSales fi

    INNER JOIN dbo.DimDate d ON d.DateKey = fi.OrderDateKey

  GROUP BY d.CalendarYear

The end user might have a better time understanding the structure of the Dimensional Model than the transactional system. Especially, if data is obtained from different databases maybe on different servers. Is it no fun trying to explain the LinkedServer and how to use it? Consolidating the needed reporting data into a Data Mart, then Data Marts together into a Data Warehouse makes life much easier for report writers.

The date dimension can also contain columns for Weekend versus Weekday, Holiday and month markers like 2014-10 or by quarter like 2014-Q1. All these can be computed once in the dimension table and used at will by query writers. They now do not have to know how to use T-SQL functions or concatenate substrings of “CASTed” date columns.

Then, when the DimDate is related to various Fact tables and processed into an OLAP cube, the measures and aggregations are displayable side by side through the DimDate dimension which is now considered a Conformed Dimension. The slicing and dicing of data has just been made a whole lot easier.

SQLSaturday Atlanta #521 May 19th & 20th 2016

SQLSaturday events are a pleasure to be a part of whether it involves speaking or volunteering. Volunteering definitely takes more work and time, but to see someone who is interested in SQL Server as a career take time to learn on a Saturday, makes it all worth the effort. When speaking, I tend to gravitate toward those 3-5 in the front row that seem full of questions, and away from that 1-2 that seemed to “know” more than me.


Friday May 20th 2016, I have be selected to present a full-day session on Reporting with Dimensional Modeling and Microsoft Business intelligence. These are called pre-conference sessions which reflects their purpose at larger conferences like PASS Summit. What makes them more attractive to attendees (AND Bosses) is the fact that you do not have to travel to the larger conference plus they are usually less expensive. This translates to a higher ROI (Return On investment) for you or the company you work for.


Atlanta’s SQLSaturday this year is May 21st 2016 at Georgia State University in Alpharetta just north of Atlanta. The speaker lineup is incredible and I know half my day will be attending sessions to advance my knowledge with the Microsoft data Platform plus talk about Transitioning from a DBA to Data Warehouse Architect.


If you are interested in learning about dimensional modeling and MSBI, please register for the day long pre-conference session I am giving, or you might be interested in the other 2 all-day sessions – Enterprise Scripting by the Midnight DBAs (Sean and Jen McCown) or SQLSentry’s Kevin Kline on 50 Things All SQL Server Developers Need to Know. There is also a half-day session on Friday presented by Linchpin People’s Brian Moran talking about Secrets of independent Consulting.


Of course, the Saturday event is free (you might have to pay for lunch). You could learn a lot of pertinent skills on Saturday as well as network with probably 500+ attendees and speakers along with sponsors and volunteers. Please come join us.


Analysis Services: Solving Hierarchy Errors of Uniqueness

Multidimensional Cubes provide speed when it comes to retrieving aggregations that are important to business decisions. Being able to slice or group the measures by dimension attributes helps with a quick analysis and flexible/interactive reporting. Configuring these attributes as hierarchies has some details that are not at first obvious. The error message when these problems exist is not extremely helpful for someone new to cubes.

Let’s look at creating a Date hierarchy with Year, Quarter, Month and Day. Our cube already has measures created from a sales fact table and the dimension for date has been created without any hierarchies.


Figure 1: Attribute List for Date Dimension

The measures can be displayed in a Pivot Table in Excel. Figure 2 below shows the Sales amount sliced by Sales Territory and Year/Quarter/Month.


Figure 2: Pivot Table in Excel

Figure 2 show the Year, Quarter and Month as Rows while the Sales Territory is used as columns with Internet Sales used for Values in the Pivot Table. Users will get frustrated when they have to pick one attribute at a time when logically the hierarchy is known.

To create this hierarchy, you need to edit the date dimension in the cube.


Figure 3: Edit Date Dimension in SQL Server Data Tools

To create a hierarchy, you can drag and drop the first or top level of the hierarchy from the Attributes pane into the hierarchies’ pane. We will do this with Year at the top level.


Figure 4: Drag Year to Create New Hierarchy

To finish this hierarchy, drag the Quarter under the Year followed by the Month and Dates attributes. To complete the Hierarchy, right-click on the name Hierarchy, and select Rename. We renamed the hierarchy to Y-Q-M-D.


Figure 5: Y-Q-M-D Hierarchy Created

We can deploy this project and preview in Excel to see the effects.


Figure 6: Preview Hierarchy Y-Q-M-D in Excel

So, what is the problem at this point? Well, for performance reasons, there is a blue line under the hierarchy name in the Cube project. The message tells use to create an attribute relationship for the hierarchy. This is done by editing the date dimension using the Attribute Relationship tab.


Figure 7: Attribute Relationship Does Not Exist.

Y-Q-M-D is a natural hierarchy because a Day is in a Month that is in a Quarter that is in a Year. So, we should be able to show that in the Attribute Relationship for this Hierarchy. You can drag and drop Quarter on Year, then drag and drop Month on Quarter to accomplish this. Dates is the root attribute or key to the dimension.

clip_image016      clip_image018

Figures 8 & 9: Before and After Y-Q-M-D Hierarchy

Now, when we deploy, we get an error. The error message with the red circle and white x does not tell us the problem. The problem is in the last warning indicating that Quarter has duplicates for value 4. In order for attribute relationship to exist, the values in each have to be unique across all occurrences. The Quarter 4 (as well as 3, 2 and 1) are duplicated for every year we have in the data dimension table.


Figure 10: Deployment Failed

There are a couple of solutions for this problem, but we are only going to look at one. We are going to use multiple columns in the KeyColumn property of the Quarter and Month to create uniqueness. Then, we have to add a column to the NameColumn property in order to have something display for the multi-column KeyColumn property.


Figure 11: Changing the KeyColumn of Attribute Quarter

To do this, you have to highlight the Quarter attribute in the Attributes’ pane, then go to the properties. Find the KeyColumn and click on the ellipse. When prompted, add CalendarYear to the Key Columns list and move the Year above the Quarter (Figure 11). Do the same thing for Month, add CalendarYear to the KeyColumn.


Figure 12: NameColumn for Month Attribute

The NameColumn needs to be change from nothing to CalendarQuarter for Quarter attribute and EnglishMonthName for Month attribute (Figure 12). Re-deploy the project and the error should no longer exist and we get a Deployment Competed Successfully.


Figure 13: Deployment Completed Successfully

The use of an Attribute Relationship for natural hierarchies greatly improves the processing and retrieval of data from the cube. This also assists the aggregation builder for indexing the combination of dimension attributes needed for analysis. In the end, the cube can retrieve the aggregation from the month to get quarter or quarter values to get the year which saved retrieving details to aggregate up the hierarchy.

Cost Threshold and Max Degree of Parallelism

SQL Server has many options for configuring a database system. Most do not become apparent until some part of the system does not function “properly”. Parallelism is one of these settings. You will see Waits for Parallelism and blocking if this setting is not effective. The SQL Server instance defaults for Max Degree of Parallelism is 0 and Cost Threshold is 5. What does this mean?


Advanced SQL Server Instance Properties

Maybe it is best to explain with an example. The machine used to write this blog has 4 CPUs in one Core. So, it is possible for a query or process in SQL Server to run on all 4 CPUs (Threads) at the same time. Because the default for Max Degree of Parallelism is 0, all CPUs are used when a process or query runs in parallel. I can change this to 2 and all processes or queries can only use a maximum of 2 CPUs unless a MAXDOP is specified in the query or process to use more or less.

Let’s look at a query that runs in parallel.

USE AdventureWorks2014

SELECT sod.SalesOrderID, sod.SalesOrderDetailID, sod.LineTotal
  , p.Class, p.ListPrice, p.Name
FROM Sales.SalesOrderDetail sod
INNER JOIN Production.Product p ON sod.ProductID = p.ProductID

The SET STATISTICS XML ON will produce a second result from running the query that is the XML of the execution plan.


Adventure Works query running in parallel

By clicking on the XML output, you will get the Execution Plan for the query.


Parallel Query

The operators (Hash Match is one) with the yellow double arrows indicate a parallel process during the execution of the plan. If we add OPTION (MAXDOP 1) to the query, it will not run in parallel and we will be able to see the Cost of the query when not running in parallel. This option forces the query to run as with one CPU (Thread) without any parallelism. We could also change the Max Degree of Parallelism on the instance but this would be system wide.


SELECT sod.SalesOrderID, sod.SalesOrderDetailID, sod.LineTotal
  , p.Class, p.ListPrice, p.Name
FROM Sales.SalesOrderDetail sod
INNER JOIN Production.Product p ON sod.ProductID = p.ProductID

The following is the details of the query plan and cost. The cost of this query will be approximately 6.8.


No Parallelism with MADOP 1


Cost of Query

Now, if we change the Cost Threshold of Parallelism on the instance from 5 to 10, the cost of the query (6.8) is no longer above the threshold (10) and the query will not run in parallel even without the MAXDOP 1 option.


Change Cost Threshold and Max Degree of Parallelism

We have changed the Cost Threshold of Parallelism to 10 for the instance as well as the Max Degree of Parallelism to 2. The 2 will be an instance wide setting to not use more than 2 CPUs for a query or process unless the OPTION MAXDOP is used in the query or process. We will see this in the properties of the parallel operator in the screen below.

SELECT sod.SalesOrderID, sod.SalesOrderDetailID, sod.LineTotal
  , p.Class, p.ListPrice, p.Name
FROM Sales.SalesOrderDetail sod
INNER JOIN Production.Product p ON sod.ProductID = p.ProductID


No Parallelism with New Cost Threshold

If I change the Cost Threshold back to 5, I will get parallelism with 2 CPUs.


MAXDOP2 Shown In Hash Match Operator Properties

You can now see in the properties of the Hash Match the Actual Number of Rows has 3 threads. The 0 zero thread controls the other 2 threads – 1 and 2. 1 and 2 are the 2 CPUs used to run the query in parallel based on the instance setting of 2 for Max Degree of Parallelism.

So, in conclusion, the MAXDOP feature is for the number of CPUs available for queries or processes (like Backups) to run in parallelism. The Cost Threshold is the value of the Cost of a query that triggers the Query Processer to see if parallelism will help a query or process.