Jeff Prom's SQL Server Blog

Sharing knowledge and tips on SQL Server, Business Intelligence and Data Management.

SQL Saturday # 661 – San Diego 2017

Posted by jeffprom on September 21, 2017

While only a few days away, there is still time to register and attend the SQL Saturday San Diego event! I will be presenting on SQL Injections and how to stop them. Come spend the day learning about SQL Server and listening to a great lineup of speakers.

The event will be held at UCSD Extension – University City Center, 6256 Greenwich Dr., San Diego, California, 92122 on Saturday, September 23. See you there!

Advertisements

Posted in Events, Security | Leave a Comment »

SQL Saturday # 640 – Los Angeles 2017

Posted by jeffprom on May 5, 2017

I’m excited to announce that I’ll be presenting at the very first SQL Saturday event in Los Angeles!

The event is coming up fast but there is still time to register. It will be on June 10th, 2017 at the Microsoft Technology Center aka MTC, 13031 W. Jefferson Blvd Suite 200, Los Angeles, California, 90094.

Reserve your spot today! http://www.sqlsaturday.com/640/EventHome.aspx

@SQLSatLA

        

Posted in Events, MDS | Leave a Comment »

Workaround for Self-Joining Table Limitations on Indexed Views

Posted by jeffprom on March 27, 2017

Indexed views are special views that can offer huge performance improvements over regular views. They perform faster because they are stored in the database the same way a table is stored. They also have a unique clustered index which greatly improves performance. However, these benefits come at a price. Indexed views have a lot of limitations to consider before implementation.

To see the full list of limitations and to learn more about indexed views, click here:
https://docs.microsoft.com/en-us/sql/relational-databases/views/create-indexed-views

Recently, I was creating several indexed views and came across a limitation of joining to the same dimension table multiple times (role-playing dimension). I received the following error message: Cannot create index on view “x_DW.dbo.vw_SchemaBoundView_Test”. The view contains a self join on “x_DW.dbo.DimUser”.

Google searching resulted in several not-so-great suggestions to overcome this limitation. I believe the best solution was to create a new table and essentially writing duplicate data values to this new table. For example; create a dbo.DimUser2 table. I really do not like this approach because I would have to create another table for one single purpose and maintain the ETL and data for this one purpose.

After some thinking, I came up with another solution which requires less maintenance and seems to have good performance with less overhead. I broke my views up into two views: ViewName and ViewName_Base. The Base view has essentially everything minus the second join to the same table. I identified which of the two self-joining tables had the greatest amount of columns or caused the biggest performance hit. This was the join I included in my Base view because it will get stored like a table and indexed. I created the base view with schemabinding and created the unique clustered index.

Next, I created the other, non-base, view. This was nearly identical to the Base view. However, it’s primary source is the Base view. I then joined the Base view to the other self-joining table reference to get the final desired columns which I needed in my select statement.

By splitting the original view into two views, I was able to work around the self-joining table limitation in indexed views but was still able to have a really nice performance improvement. I did not need to create additional ETL or need to create another table with duplicate data that I would need to maintain.

Posted in T-SQL, Tips | Tagged: | Leave a Comment »

Jet Driver Error When Importing Data from Excel Files

Posted by jeffprom on March 24, 2017

Importing data from files is common. Csv file formats are also common but can cause issues with characters such as commas. Excel files offer a nice solution as they are usually formatted properly and do not have issues with characters. However, there can also be a common problem scheduling a job to load the data due to a jet driver issue.

ImportData:Error: The requested OLE DB provider Microsoft.Jet.OLEDB.4.0 is not registered. If the 64-bit driver is not installed, run the package in 32-bit mode. Error code 0x00000000. An OLE DB record is available. Source: “Microsoft OLE DB Service Components” Hresult: 0x80040154 Description: “Class not registered”.

Here is how to overcome this error. First, install the ‘Microsoft Access Database Engine 2010 Redistributable‘ file which will provide the required jet driver.

Next, open the SSIS package/solution in visual studio and click on Project, <project name> Properties. On the Configuration Properties, Debugging tab, Set Run64BitRuntime = False. The jet driver is only 32 bit.

There is one final step and that is a configuration setting on the SQL Agent job itself. Without setting this, it will fail. Edit the job, click on Steps and edit the step. On the General tab, click on Configuration, Advanced and check the box that says 32-bit runtime.

That’s it! Execute the job and it should now finish successfully.

Posted in Excel, SSIS, Uncategorized | Tagged: , | Leave a Comment »

SQL Saturday #611 – Orange County 2017

Posted by jeffprom on February 22, 2017

sqlsat611_web

SQL Saturday Orange County is coming up fast! The event will be on April 1st, 2017 at Golden West College, 15744 Goldenwest St, Orange County, California, 92647.

Reserve your spot today by going here: http://www.sqlsaturday.com/611/EventHome.aspx

I’ll be presenting two sessions:

  • SQL Injections and How To Stop Them
  • Mastering Master Data Services (Lots of changes in SQL Server 2016!)

Posted in MDS, Security | Leave a Comment »

SQL Saturday #497 – Huntington Beach 2016

Posted by jeffprom on March 14, 2016

sqlsat497_web

April is shaping up to be a fun, yet busy month. I have also been selected to present two topics at SQL Saturday #497 in Huntington Beach on April 2nd! I will be presenting on SQL Injections and Master Data Services. Here are descriptions of my presentations.

SQL Injections and How to Stop Them

Right now, there are hackers all around the world trying to get into your web applications. How safe are you? By using a technique called SQL injections, hackers can wreak havoc with web applications by compromising security, manipulating data, hoarding system resources, retrieving sensitive information, and manipulate data database objects such as dropping databases!

During the demo, we will take on a couple of different roles. As a hacker we will walk through steps a hacker might take to compromise a web application in order to retrieve sensitive data such as credit card information, usernames, passwords, and social security numbers. Assuming the role of a developer, we will then show various prevention techniques and their effectiveness in preventing SQL injections.

Attend this session to learn how SQL injections work, identify if you are being attacked, and how to stop them.

Update: Thank you to everyone who attended my session. We had a full room! 🙂

As requested, you can download the presentation and scripts here.

jeffprom-presenting

Mastering Master Data Services

As your organization grows, one challenge will be the management of data between systems and organizational units. With MDS, Microsoft provides the ability to have one accurate source of non-transactional data. This data can then be used within applications, other databases, and ETL processes. By leveraging data stewards to help manage the data repository, you can ensure that your MDS data is always up-to-date and accurate.

In this presentation we will cover MDS from start to finish including installation, creating models/entities, working with data, using the Excel add-in, security, hierarchies, views, versions, and business rules. After this presentation, you will have a good understanding of what master data management is, what MDS does, how to use it, and how to get started with your own MDS project.

To register for this event and to find additional information, you can visit the SQL Saturday Huntington Beach page here:
http://www.sqlsaturday.com/497/EventHome.aspx

Posted in Events, MDS, Security | 1 Comment »

SQL Saturday #492 – Phoenix 2016

Posted by jeffprom on March 9, 2016

sqlsat492_web
I recently moved from Minneapolis, Minnesota to San Diego, California. I’m certainly enjoying the warmer weather and am excited that I can check out SQL Saturday events in a new area. Along those lines, I am happy to announce that I have been accepted to present on Master Data Services at SQL Saturday #492 in Phoenix on April 16th! Below is a description of my presentation. I hope to see you at this event!

Mastering Master Data Services

As your organization grows, one challenge will be the management of data between systems and organizational units. With MDS, Microsoft provides the ability to have one accurate source of non-transactional data. This data can then be used within applications, other databases, and ETL processes. By leveraging data stewards to help manage the data repository, you can ensure that your MDS data is always up-to-date and accurate.

In this presentation we will cover MDS from start to finish including installation, creating models/entities, working with data, using the Excel add-in, security, hierarchies, views, versions, and business rules. After this presentation, you will have a good understanding of what master data management is, what MDS does, how to use it, and how to get started with your own MDS project.

To register for this event and to find additional information, you can visit the SQL Saturday Phoenix page here:
http://www.sqlsaturday.com/492/EventHome.aspx

Posted in Events, MDS | Leave a Comment »

Formatting Power Query Columns

Posted by jeffprom on September 30, 2015

Power Query is a great tool to quickly, and easily, load data into an Excel workbook. However, on the surface one potential drawback is the lack of formatting one can apply to the columns. This post will describe in further detail what I mean and show how to overcome this issue.

First, let’s take a look at how Power Query doesn’t work very well with formatting columns. Here I am pulling a set of data into Power Query and looking to format various columns with appropriate data types such as integer, currency, and date. I set the appropriate data types.

Whole Number

pq - whole number

Currency

pq - currency

Date

pq - date

Now that we set the data types, do a Close & Load to load the data into the Excel worksheet. We can inspect each column that we formatted and will see that the Whole Number and Currency turned into a General format. However, the Date data type actually does come through as a Date format.

Whole Number

pq - whole number - after load

Currency

pq - currency - after load

Date

pq - date - after load

Now let’s look at how we can actually format the number (integer), and currency columns. Yes, we can set it in Excel like normal but the problem is that when you refresh the data it will revert back to non-formatted columns. To get around this, click on the Data tab at the top and select Properties.

pq - data properties

Check the box that says ‘Preserve column sort/filter/layout’.

pq - preserve column layout

You can now format the columns in Excel like normal and it will retain formatting changes after data has been refreshed!

pq - format preserved

This works very well and you can format data just like normal in Excel. The only downside is that it is workbook specific. If you use the same query, possibly from the Power BI Data Catalog query, it will not retain the formatting changes and you will need to format each column again in every workbook you use.

Posted in Excel, Power Query | Leave a Comment »

Sorting a Chart in SSRS

Posted by jeffprom on March 20, 2015

Sorting a chart in SSRS sounds easy enough, but the sort option isn’t where you might expect to find it. In this example I am using Visual Studio 2012.

First let’s take a look at an unsorted chart. Even if you sort values in your underlying dataset, your chart will likely not be sorted.

ssrs chart unsorted

One might expect to find sort options by right clicking the chart and going to Chart Properties which will not work. You then might think, of course it must be on the Series Properties. However, that again will not work. So let’s take a look at how to sort the chart. Start by double clicking the chart which will bring up the Chart Data box. Now you will probably expect to find sort options by looking at Value options.. and you would be wrong yet again. Click on the drop down arrow under the Category Groups. Select Category Group Properties.

ssrs chart select category group

Here you will find a Sorting option. Click Add and select what you would like to sort on.

ssrs chart add sort order

Now you can see that we finally have a sorted chart.

ssrs chart final sorted result

Posted in SSRS | Tagged: , | 1 Comment »

SSRS Chart Does Not Show All Labels

Posted by jeffprom on March 2, 2015

When creating a new chart in SSRS, you may find that not all of the labels are being displayed on either the vertical or horizontal axis. This will happen when the chart tries to determine how many labels it can show using the default setting. Sometimes this isn’t the best solution. For example, as you can see in my chart below there should be plenty of room to show all of the labels but it decides not to.

ssrs chart final sorted result

In this case we definitely want to show all of the labels. To do this we will need to adjust some settings. Double click on the label names on the chart.

ssrs select label names

On the right hand side of Visual Studio, you should now see the Chart Axis values on the Properties area.

ssrs axis properties

Under the Interval attribute, change the value from ‘Auto’ to 1. This will specify that we want to show labels on every occurrence.

ssrs set interval value

Re-run the report and now you can see that all of the labels are shown.

ssrs chart with all labels

Posted in SSRS | Tagged: , | Leave a Comment »