SQL Server – Interface Technical Training https://www.interfacett.com Wed, 21 Jun 2017 19:26:18 +0000 en-US hourly 1 Microsoft White Paper – SQL Server 2016 and Windows Server 2016 Better Together https://www.interfacett.com/blogs/microsoft-white-paper-sql-server-2016-and-windows-server-2016-better-together/ https://www.interfacett.com/blogs/microsoft-white-paper-sql-server-2016-and-windows-server-2016-better-together/#respond Wed, 07 Dec 2016 22:37:20 +0000 http://www.interfacett.com/blogs/?p=?p=23731 SQL Server 2016 and Windows Server 2016 Better Together Technical white paper (April 2016) published by Microsoft “Microsoft is pushing the limits of hardware capabilities and bringing the latest enterprise technologies to market. Both products are offering improvements to availability and disaster recovery features, providing an unprecedented level of interoperability in a variety of environments.” … Continue reading Microsoft White Paper – SQL Server 2016 and Windows Server 2016 Better Together

The post Microsoft White Paper – SQL Server 2016 and Windows Server 2016 Better Together appeared first on Interface Technical Training.

]]>
SQL Server 2016 and Windows Server 2016 Better Together
Technical white paper (April 2016) published by Microsoft

microsoft-white-paper-sql-server-2016-and-windows-server-2016-better-together

“Microsoft is pushing the limits of hardware capabilities and bringing the latest enterprise technologies to market. Both products are offering improvements to availability and disaster recovery features, providing an unprecedented level of interoperability in a variety of environments.”

For more, download the entire Microsoft white paper SQL Server 2016 and Windows Server 2016 Better Together.

 

 

The post Microsoft White Paper – SQL Server 2016 and Windows Server 2016 Better Together appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/microsoft-white-paper-sql-server-2016-and-windows-server-2016-better-together/feed/ 0
How to Display the Elapsed Processing Time of a Report in SSRS https://www.interfacett.com/blogs/how-to-display-the-elapsed-processing-time-of-a-report-in-ssrs/ https://www.interfacett.com/blogs/how-to-display-the-elapsed-processing-time-of-a-report-in-ssrs/#respond Mon, 28 Sep 2015 18:15:01 +0000 http://www.interfacett.com/blogs/?p=?p=21581 The amount of time it takes to process a report can be useful information for performance auditing. Although there isn’t a built-in field in SQL Server Reporting Services that holds the elapsed processing time, it’s easy to create this functionality using the ExecutionTime built-in field and the Now VB.Net function in SSRS. For instructor-led SQL … Continue reading How to Display the Elapsed Processing Time of a Report in SSRS

The post How to Display the Elapsed Processing Time of a Report in SSRS appeared first on Interface Technical Training.

]]>
The amount of time it takes to process a report can be useful information for performance auditing. Although there isn’t a built-in field in SQL Server Reporting Services that holds the elapsed processing time, it’s easy to create this functionality using the ExecutionTime built-in field and the Now VB.Net function in SSRS.

For instructor-led SQL Server Training see our complete course schedule.  

The ExecutionTime is the moment when report processing starts. When used in the expression of a textbox, the Now function returns the time when the report is rendered. Rendering comes right after report processing. This means we can easily calculate the processing time simply by subtracting Now from ExecutionTime.

Function Implementation

One way to implement the logic is to put it into a custom function and then call the function from the expression of a textbox. This is clean, the code is easy to read and so it’s also easy to maintain. The downside is that you have more than one component to the solution; so, if you want to copy this functionality into other reports, you’ll have to copy and paste both the function and the textbox. My preference would be for this approach because “clean and easy to maintain” usually leads to smoother running programs!

If you’ve never created custom code in SSRS before, read my article on Using Custom Code in SSRS to see how it’s done. Then create the following function that will both calculate the elapsed processing time and return it as a string in the format mm:ss.

Function ProcessingTime(StartTime As Date, EndTime as Date) As String

Dim ElapsedMins As Integer = DateDiff(DateInterval.Minute, StartTime, EndTime) mod 60 
Dim ElapsedSecs As Integer = DateDiff(DateInterval.Second, StartTime, EndTime) mod 60

Return ElapsedMins.ToString() & ":" & Right("0" & ElapsedSecs.ToString(), 2)

End Function

Single Expression Implementation

Another way to implement the logic is to use a single expression in a textbox (right-click the textbox and select Expression…) that does everything. This is a bit messier, the expression has a whole bunch of things piled into it making it harder to read and maintain, but all you have to do to put it into another report is copy just that one textbox containing the following expression, which also displays the results in the format mm:ss.

=DateDiff(DateInterval.Minute, Globals!ExecutionTime, Now()) mod 60 & ":" & Right("0" & 
DateDiff(DateInterval.Second, Globals!ExecutionTime,  Now()) mod 60, 2)

 

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post How to Display the Elapsed Processing Time of a Report in SSRS appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/how-to-display-the-elapsed-processing-time-of-a-report-in-ssrs/feed/ 0
Microsoft Second Shot Exams Are On! https://www.interfacett.com/blogs/microsoft-second-shot-exams-are-on/ https://www.interfacett.com/blogs/microsoft-second-shot-exams-are-on/#respond Mon, 31 Aug 2015 20:20:09 +0000 http://www.interfacett.com/blogs/?p=?p=21473 Plenty of IT professionals are looking to start or expand their certifications. If you’re interested in pursuing Microsoft certification, now is a great time! Microsoft periodically runs a Second Shot promotion. What it means is that if you don’t pass your first attempt at an exam, Microsoft gives you a free retake of that exam. … Continue reading Microsoft Second Shot Exams Are On!

The post Microsoft Second Shot Exams Are On! appeared first on Interface Technical Training.

]]>
Plenty of IT professionals are looking to start or expand their certifications. If you’re interested in pursuing Microsoft certification, now is a great time!

Microsoft periodically runs a Second Shot promotion. What it means is that if you don’t pass your first attempt at an exam, Microsoft gives you a free retake of that exam. It has to be the same exam, and you have to register for the retake within 30 days of your first exam.

Why is this so important? To be honest, many test takers fail for a single reason: stress. Test anxiety is a real thing, and it’s more impactful than you might realize. Second Shot helps to reduce that stress. If you don’t pass, so what? Less stress with a free retake option often results in a higher pass rate the first time. And Microsoft’s own statistics show that more than 90% of candidates who fail the first attempt pass the second.

The Second Shot promotion is running until January 12, 2016. So plan to take and pass an exam soon!

Enjoy!

Mike Danseglio – CISSP, MCSE, and CEH

Mike Danseglio teaches IT Security Training, Windows, System Center and Windows Server 2012 classes at Interface Technical Training. His classes are available in Phoenix, AZ and online with RemoteLive™.

The post Microsoft Second Shot Exams Are On! appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/microsoft-second-shot-exams-are-on/feed/ 0
Optional Parameters in SSRS https://www.interfacett.com/blogs/optional-parameters-in-ssrs/ https://www.interfacett.com/blogs/optional-parameters-in-ssrs/#comments Mon, 27 Jul 2015 16:13:22 +0000 http://www.interfacett.com/blogs/?p=?p=21139 Let’s say you have a report, like a sales report that shows sales orders, and some people who run that report need it to show only the one sales order that they specify while others need to see all sales orders. In this article, I’ll show you how to create an optional parameter that allows … Continue reading Optional Parameters in SSRS

The post Optional Parameters in SSRS appeared first on Interface Technical Training.

]]>
Let’s say you have a report, like a sales report that shows sales orders, and some people who run that report need it to show only the one sales order that they specify while others need to see all sales orders. In this article, I’ll show you how to create an optional parameter that allows you to implement this type of flexibility.

To accomplish this, two things need to be done. The first is to create an optional parameter, or a parameter that does not stop SSRS from running the report if no value for it is supplied. The second is to tell the report to select all the data when a value for the parameter is not supplied and to select only some of the data when a value is supplied.

Create an Optional Parameter

  1. With the report open and the Design tab selected, right-click the Parameters folder in the Report Data pane and select Add Parameter…

Add a Parameter in SSRS SQL Server Reporting Services

  1. In the Report Parameter Properties window, make the following entries and selections. Notice that Allow null value is checked.

Allow Null values feature in in SSRS SQL Server Reporting Services

When the parameter does not allow nulls, SSRS will not run the report if a value for the parameter is not supplied. By telling the report to allow nulls, SSRS will run the report regardless.

  1. Click OK when done.

The next step is to wire up the parameter to the data selection process of the report and to tell the report what to do if no value is supplied.

Configure the Report for the Optional Parameter

Our parameter will be used in the WHERE clause of the query in the dataset, though the same approach applies if you use it in a filter. (I’m putting the query directly in the dataset of the report to simplify this article, but you should always consider using stored procedures when developing reports; among the many benefits that stored procedures offer are that they are faster and keep data access organized and manageable. The same strategy shown in this article can be applied in a stored procedure.)

  1. Right-click the dataset in the Report Data pane and select Dataset Properties.

Selecting Dataset property in SSRS SQL Server Reporting Services

  1. Add a WHERE clause to the query that restricts the data in the report to the value of the parameter. Include an OR clause that returns True if the parameter is null; that way, the WHERE clause will be True for every row of the query when the parameter is not used.

Adding a WHERE Claues in in SSRS SQL Server Reporting Services

Now, when you run your report, you can either supply a value for the parameter or just ignore it and the report will know what to do in each case.

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post Optional Parameters in SSRS appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/optional-parameters-in-ssrs/feed/ 3
A Real-World Example of a Non-Correlated SELECT Subquery and Cross Join https://www.interfacett.com/blogs/real-world-example-non-correlated-select-subquery-cross-join/ https://www.interfacett.com/blogs/real-world-example-non-correlated-select-subquery-cross-join/#respond Wed, 08 Apr 2015 17:04:12 +0000 http://www.interfacett.com/blogs/?p=?p=20118 I recently developed a solution to a problem that is a good example of a non-correlated subquery in a SELECT clause that can also be written as a cross join. I’ll describe the requirement, the data, and then the solution with a non-correlated subquery and another with a cross join. To keep my client and … Continue reading A Real-World Example of a Non-Correlated SELECT Subquery and Cross Join

The post A Real-World Example of a Non-Correlated SELECT Subquery and Cross Join appeared first on Interface Technical Training.

]]>
I recently developed a solution to a problem that is a good example of a non-correlated subquery in a SELECT clause that can also be written as a cross join. I’ll describe the requirement, the data, and then the solution with a non-correlated subquery and another with a cross join. To keep my client and their data anonymous, I’ve translated the problem to the AdventureWorks database.

The Requirement

The client wanted to see, for each sales person who placed orders over a time period, their total sales and their “productivity” over that time period. They defined productivity as the total sales divided by the number of business days in that time period. Here is the output that meets the requirement and that our solution will have to produce. This is for the time period of March, 2004, given the data in the AdventureWorks database.

001-non-Correlated-SELECT-Subquery-and-Cross-Join

The Data

The AdventureWorks database contains a table called Sales.SalesOrderHeader that holds sales orders. There are three columns in that table that are of interest to us: SalesPersonID, OrderDate, and TotalDue. Here is a sample of the data in those columns, formatted for a clean presentation, and including only the data for the time period of March, 2004 that I will use to test the solution, though not all rows in that time period are shown:

USE AdventureWorks

SELECT SalesPersonID
, CONVERT(VARCHAR, OrderDate, 101) AS OrderDate
, '$' + CONVERT(VARCHAR, TotalDue, 1) AS TotalDue
FROM Sales.SalesOrderHeader

002-non-Correlated-SELECT-Subquery-and-Cross-Join

In addition, I have created a table called DimDate that is similar to the one my client has in their database. DimDate is a dimension table in a data warehouse. (As we see in the Data Warehouses course, it is useful to store dates in a data warehouse in a date dimension table in which each row represents a different date). The IsBusinessDay column is a bit data type in which a 1 means that the date is a business day and a zero means that it is not. To simplify things for this example, I have created dates only for the date range I will be using in this example—March, 2004—and flagged only weekend dates as non-business days. Here is the script I used to create the DimDate table and to show its contents:

-- Create the DimDate table

USE AdventureWorks

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND  TABLE_NAME = 'DimDate')
	DROP TABLE dbo.DimDate

CREATE TABLE dbo.DimDate
(
  OrderDate DATE NOT NULL
, IsBusinessDay BIT NOT NULL
)

--Populate the DimDate table

DECLARE @StartDate DATE = '3/1/2004', @EndDate DATE = '3/31/2004'
DECLARE @CurrDate DATE = @StartDate

WHILE @CurrDate <= @EndDate
   BEGIN
      INSERT INTO dbo.DimDate
	     VALUES (@CurrDate, CASE WHEN DATEPART(WEEKDAY, @CurrDate) NOT IN (1,7) THEN 1 ELSE 0 END)
	  SET @CurrDate = DATEADD(DAY, 1, @CurrDate)
   END 

SELECT *
FROM dbo.DimDate

003-non-Correlated-SELECT-Subquery-and-Cross-Join

The Solution

Step 1: Create the Base Query that Aggregates by the Salespersonid

The output you saw earlier that meets the requirement shows one row for every sales person, along with a sum of the TotalDue column for each sales person and the number of business days. Even though the number of business days will be the same for each salesperson, it needs to be included on every row so that we can divide each salesperson’s sum of total due by the number of business days.

We’ll start with the following query that finds the sum of the total due for each employee for the test time period of March, 2004. Notice that we group by the SalesPersonID to get one row per sales person and then we sum the TotalDue for each sales person. Notice also that in this phase we are not yet doing any formatting of the output, because we need the TotalDue to remain a numeric value for when we divide it by the number of business days in a subsequent phase.

SELECT SalesPersonID
, SUM(TotalDue) AS TotalDue
FROM Sales.SalesOrderHeader
WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
GROUP BY SalesPersonID

004-non-Correlated-SELECT-Subquery-and-Cross-Join

By the way, notice that there is a NULL SalesPersonID. A SalesPersonID is NULL when the order is taken  electronically over the company’s website. Let’s clean that up a bit. We’ll use the ISNULL() function to display “Internet Sale” when the SalesPersonID is NULL. There’s just one small problem with that approach, though. The ISNULL() function requires that both of its arguments be the same data type, and our two arguments are not; SalesPersonID is an integer and “Internet Sale” is character. If we do nothing and leave it up to SQL Server, it will attempt to perform an implicit conversion. In an implicit conversion, the lower data type (character, in this case) is converted up to the higher data type (integer, in this case), and that would fail because “Internet Sale” does not resemble an integer! So, we will need to perform an explicit conversion and cast the SalesPersonID down to a character. Here is the revised query:

SELECT ISNULL(CAST(SalesPersonID AS VARCHAR), 'Internet Sale') AS SalesPersonID
, SUM(TotalDue) AS TotalDue
FROM Sales.SalesOrderHeader
WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
GROUP BY SalesPersonID

005-non-Correlated-SELECT-Subquery-and-Cross-Join

Step 2: Include the Number of Business Days

We can very easily find the number of business days for a time period by filtering the DimDate table to return only days where IsBusinessDay = 1 within the time period we want. Here is a query that does just that for our time period of March, 2004 (there were 23 business days in March, 2004):

SELECT COUNT(*) NumBusDays
FROM dbo.DimDate
WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
  AND IsBusinessDay = 1

006-non-Correlated-SELECT-Subquery-and-Cross-Join

Notice that this query returns a single row and a single column. A query that returns a single value like this is referred to as a scalar query. Because the query above is scalar, it can be used as a column in a SELECT clause. Just one problem: The GROUP BY clause in our base table won’t allow us to do that, because the GROUP BY demands that the only two things in the SELECT clause be what is in the GROUP BY clause and aggregate functions. We can get around this in a couple of ways.

One way is by making our base query a derived table subquery and including the scalar query in the outer query.

In the query below, BaseQuery is the base query we developed earlier, and BusDays is the scalar query that returns the number of business days in our time period. NumBusDays is a subquery in the SELECT clause; it occupies a column position in the outer SELECT. The outer query displays all the columns in the base query (BaseQuery.*) and the row count returned by NumBusDays.

SELECT BaseQuery.*, (SELECT COUNT(*) As TotBusDays
                     FROM dbo.DimDate
                     WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
                       AND IsBusinessDay = 1
                    ) AS NumBusDays
FROM (SELECT ISNULL(CAST(SalesPersonID AS VARCHAR), 'Internet Sales') AS SalesPersonID
      , SUM(TotalDue) AS TotalDue
      FROM Sales.SalesOrderHeader
      WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
      GROUP BY SalesPersonID
     ) AS BaseQuery

007-non-Correlated-SELECT-Subquery-and-Cross-Join

The other way to accomplish the same results is by using a cross join. A cross join joins two tables by matching up every row in one table with every row in the other table. Since we want the single row returned by our scalar query to appear on every row of our aggregate query, a cross join would also work (any query that uses a non-correlated subquery in a Select clause can also be written as a cross join).

SELECT BaseQuery.*, TotBusDays.NumBusDays.
FROM (SELECT ISNULL(CAST(SalesPersonID AS VARCHAR), 'Internet Sales') AS SalesPersonID
      , SUM(TotalDue) AS TotalDue
      FROM Sales.SalesOrderHeader
      WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
      GROUP BY SalesPersonID
     ) AS BaseQuery
     CROSS JOIN 
     (SELECT COUNT(*) As NumBusDays
      FROM dbo.DimDate
      WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
        AND IsBusinessDay = 1
     ) AS BusDays

008-non-Correlated-SELECT-Subquery-and-Cross-Join

You can run both queries with the actual execution plan on to see if one is more efficient than the other. In this example, they are both the same—neither approach is faster or more efficient than the other, though you should not always count on this being the case; it’s always a good idea to compare both execution plans as there are many factors that can effect the outcome.

Step 3: Calculate the Productivity and Format the Output

At this point, we have everything we need on one row to allow us to divide the sum of the TotalDue column by the number of business days. All we have to do now is add another column to the outer query that performs that division; but in the subquery approach, if we do it that way, we’d have to repeat the scalar query as the denominator. To avoid that, we can make a derived table out of everything we have so far and then use the column aliases, instead. We can also format things nicely in the new outer query. Much easier!

Compare the results of this query with the results shown in the Requirements section above; they are the same.

SELECT SalesPersonID
, '$' + CONVERT(VARCHAR, TotalDue, 1) AS SumTotalDue
, NumBusDays
, '$' + CONVERT(VARCHAR, TotalDue/NumBusDays, 1) AS Productivity
FROM (SELECT BaseQuery.*, (SELECT COUNT(*) As TotBusDays
                           FROM dbo.DimDate
                           WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
                             AND IsBusinessDay = 1
                          ) AS NumBusDays
      FROM (SELECT ISNULL(CAST(SalesPersonID AS VARCHAR), 'Internet Sales') AS SalesPersonID
            , SUM(TotalDue) AS TotalDue
            FROM Sales.SalesOrderHeader
            WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
            GROUP BY SalesPersonID
           ) AS BaseQuery
     ) EverythingWeNeed
ORDER BY Productivity DESC

009-non-Correlated-SELECT-Subquery-and-Cross-Join

With the cross join, the new outer query is not even necessary:

SELECT BaseQuery.SalesPersonID
, '$' + CONVERT(VARCHAR, BaseQuery.TotalDue, 1) As SumTotalDue
, BusDays.NumBusDays
, '$' + CONVERT(VARCHAR, BaseQuery.TotalDue/BusDays.NumBusDays, 1) AS Productivity

FROM (SELECT ISNULL(CAST(SalesPersonID AS VARCHAR), 'Internet Sales') AS SalesPersonID
      , SUM(TotalDue) AS TotalDue
	  FROM Sales.SalesOrderHeader
	  WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
	  GROUP BY SalesPersonID
	 ) AS BaseQuery
	 CROSS JOIN 
	 (SELECT COUNT(*) As NumBusDays
	  FROM dbo.DimDate
	  WHERE OrderDate BETWEEN '3/1/2004' AND '3/31/2004'
	 	AND IsBusinessDay = 1
	 ) AS BusDays
ORDER BY BaseQuery.TotalDue/BusDays.NumBusDays DESC

010-non-Correlated-SELECT-Subquery-and-Cross-Join

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post A Real-World Example of a Non-Correlated SELECT Subquery and Cross Join appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/real-world-example-non-correlated-select-subquery-cross-join/feed/ 0
Repeating and Freezing Column Headers in SSRS Tables https://www.interfacett.com/blogs/repeating-freezing-column-headers-ssrs-tables/ https://www.interfacett.com/blogs/repeating-freezing-column-headers-ssrs-tables/#comments Mon, 09 Mar 2015 22:08:25 +0000 http://www.interfacett.com/blogs/?p=?p=19909 In this article I’ll show you how to configure a table tablix to both repeat column headers at the top of every page and freeze them while scrolling. While tablixes have properties for these things, they only work in matrix tablixes but not in tables. I’ll show you a way to accomplish these things using … Continue reading Repeating and Freezing Column Headers in SSRS Tables

The post Repeating and Freezing Column Headers in SSRS Tables appeared first on Interface Technical Training.

]]>
In this article I’ll show you how to configure a table tablix to both repeat column headers at the top of every page and freeze them while scrolling. While tablixes have properties for these things, they only work in matrix tablixes but not in tables. I’ll show you a way to accomplish these things using an approach that does work; however, be warned: the way to do this is clunky, counter-intuitive, and requires maintenance if you make certain changes to your tables.

First, let me show you the properties that don’t work in a table. For the approach I’ll be showing you here to work properly, those properties have to be set to False.

Press F4 to display the Properties Window. Then, in the dropdown at the top of the Properties window, select the tablix in your report for which you want to control column headers.

001-Repeating-and-Freezing-Column-Headers-in-SSRS-Tables

There are two properties you’re looking for. FixedColumnHeaders will prevent column headers in a matrix from scrolling off the top of the page and RepeatColumnHeaders will make sure that column headers in a matrix appear at the top of every page in the tablix. When working with tables, you want to make sure these properties are both set to False.

002-FixedColumnHeaders-Column-Headers-in-SSRS-Tables

With both of these properties set to False, we’re ready to configure the tablix to repeat and freeze the column headers. Start by putting the group panel at the bottom of the report design screen into advanced mode. Do this by selecting Advanced Mode from the dropdown off to the right side of the groups panel.

003-FixedColumnHeaders-Column-Headers-in-SSRS-Tables

Don’t be alarmed by what you see next! This is a notoriously confusing layout that many people struggle to understand. The good news is that you don’t need to understand it in order to use it for what we’re doing as long as you keep in mind that you always work with the first static item in the list. Select the first Static item and press F4 to display its properties in the Properties window.

004-Properties-Repeating-and-Freezing-Column-Headers-in-SSRS-Tables

You’ll need to set two properties to make the column headers repeat on every page: KeepWithGroup must be set to After and RepeatOnNewPage must be set to True. To prevent scrolling, set FixedData to True.

(A note of caution: Keep in mind that this approach works as long as these properties are always set on the first static item. If you change the table in a way that changes what the first row was when you set these properties, what used to be the first static item will no longer be the first one. You will have to find where that static item ended up, undo the property changes on it, and reset those properties on the new first static item.)

Alas, we are not quite out of the woods, yet. After you set the FixedData property to True, preview your report and try scrolling. Notice that the column header stays put, but because its background is transparent by default, things look messy.

005-fixedData-Properties-Repeating-and-Freezing-Column-Headers-in-SSRS-Tables

To fix this, just change the background color of the cells in the header row to something other than “No Color.” Select the top row of the table, press F4 to show the Properties window, click the dropdown of the BackgroundColor property, and chose a color, such as White or any other color (if you choose a dark color for the background, it may be difficult to read the column headers, and you may have to change the Color property, which controls the foreground color, to something light).

006-BackgroundColor-Properties-Repeating-and-Freezing-Column-Headers-in-SSRS-Tables

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post Repeating and Freezing Column Headers in SSRS Tables appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/repeating-freezing-column-headers-ssrs-tables/feed/ 6
How to Name Worksheets When Exporting SSRS reports to Excel https://www.interfacett.com/blogs/name-worksheets-exporting-ssrs-reports-excel/ https://www.interfacett.com/blogs/name-worksheets-exporting-ssrs-reports-excel/#comments Wed, 18 Feb 2015 17:05:22 +0000 http://www.interfacett.com/blogs/?p=?p=19821 Let’s say we have the following report that shows total sales by product category by territory: When we export this report to Excel, we’d like each territory to appear in its own worksheet and each worksheet named after its territory: How do we make this work? Easy! 1) Put every group on its own page, … Continue reading How to Name Worksheets When Exporting SSRS reports to Excel

The post How to Name Worksheets When Exporting SSRS reports to Excel appeared first on Interface Technical Training.

]]>
Let’s say we have the following report that shows total sales by product category by territory:

001-SQL-server-SSRS-report-to-excel

When we export this report to Excel, we’d like each territory to appear in its own worksheet and each worksheet named after its territory:

002-SQL-server-SSRS-report-to-excel

How do we make this work? Easy! 1) Put every group on its own page, and 2) name each page using the same field the group uses.

Step 1: Put each group on its own page

To put each group on its own page, open the group’s property window.

003-SQL-server-SSRS-report-to-excel

Then, in the Page Breaks category, put a check mark in the Between each instance of a group check box.

004-SQL-server-SSRS-report-to-excel

Click OK to complete this step.

Step 2: Name the pages of the group

With the group selected in the Row Groups panel, press F4 to open the Properties window.

005-SQL-server-SSRS-report-to-excel

Next, expand the Group property and look for the Page Name sub-property. From its dropdown, select <Expression…>.

006-SQL-server-SSRS-report-to-excel

In the Expression dialog, select the Fields category and then double-click on the same field the group uses; in this case that would be the Territory field.

007-SQL-server-SSRS-report-to-excel

A reference to the field appears in the window at the top of the Expression dialog.

008-SQL-server-SSRS-report-to-excel

Click OK and that’s it! Now, when you export the report to Excel, the worksheet names will match the group names!

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post How to Name Worksheets When Exporting SSRS reports to Excel appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/name-worksheets-exporting-ssrs-reports-excel/feed/ 2
Using Custom Code in SSRS https://www.interfacett.com/blogs/using-custom-code-ssrs/ https://www.interfacett.com/blogs/using-custom-code-ssrs/#comments Mon, 15 Dec 2014 16:17:52 +0000 http://www.interfacett.com/blogs/?p=?p=19512 While expressions allow you to use limited VB.Net to create advanced dynamic functionality in your SQL Server Reporting Services (SSRS) reports, custom code allows you to leverage much more of the power of VB.Net. The focus of this article is not on writing VB.Net code, but on how to create and use code in SSRS. … Continue reading Using Custom Code in SSRS

The post Using Custom Code in SSRS appeared first on Interface Technical Training.

]]>
While expressions allow you to use limited VB.Net to create advanced dynamic functionality in your SQL Server Reporting Services (SSRS) reports, custom code allows you to leverage much more of the power of VB.Net.

The focus of this article is not on writing VB.Net code, but on how to create and use code in SSRS. As such, this article uses an example with very simple VB.Net code that I assume you understand. Of course, the more VB.Net you know, the more you will be able to do with what you learn here.

Our example uses the territory sales report shown below to conditionally format the total sales so that it’s red if it’s below 5 million; blue if it’s below 10 million; green if it’s below 15 million; and black otherwise.

001-Using-Custom-Code-in-SSRS

Here’s what the report will look like when we’re done:

002-Using-Custom-Code-in-SSRS

One way to implement this is with an expression in the color property of the textbox that displays the total sales. The expression would use nested Immediate-If functions (IIF()) to decide what color to use based on the value of the total sales. Here it is:

003-Using-Custom-Code-in-SSRS

The 1-line limitation of expressions often forces us to nest functions. Nesting can make expressions difficult to write, understand, and maintain. Our expression nests IIF() functions to implement Else-If logic that is implemented much more clearly as a block structure in code (a block structure is one that occupies more than one line of code).

To write code in a report, select the Report menu and then Report Properties…

004-Using-Custom-Code-in-SSRS

Create code in the Code section. In the example shown below, we created a function called GetColor that receives as input the total sales in a parameter called Val2Color with a data type of Single. The function returns as output the color as a String value. You can create as many functions and sub-procedure methods as you need.

005-Using-Custom-Code-in-SSRS

To use the function, just call it from the Code object. Here is a call to the function from the same place where we had the expression earlier—in the color property of the textbox that displays the total sales.

006-Using-Custom-Code-in-SSRS

Don’t worry about the red squiggly. There is no error, here. SSRS is just a little confused; this won’t prevent the report from running.

Enjoy using code in SSRS!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post Using Custom Code in SSRS appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/using-custom-code-ssrs/feed/ 2
Microsoft announces changes to SQL Server 2012 MCSA Certification https://www.interfacett.com/blogs/microsoft-announces-changes-sql-server-2012-mcsa-certification/ https://www.interfacett.com/blogs/microsoft-announces-changes-sql-server-2012-mcsa-certification/#respond Mon, 17 Nov 2014 17:44:54 +0000 http://www.interfacett.com/blogs/?p=?p=19467 Are you working towards your SQL Server 2012 Microsoft Certified Solutions Associate (MCSA) credentials?  If so, you now have more options for your exams.  Starting on 15 September 2014 there are now electives for your MCSA certification. There are now 2 required exams and a choice of 1 elective from a list of 4 exams … Continue reading Microsoft announces changes to SQL Server 2012 MCSA Certification

The post Microsoft announces changes to SQL Server 2012 MCSA Certification appeared first on Interface Technical Training.

]]>
Are you working towards your SQL Server 2012 Microsoft Certified Solutions Associate (MCSA) credentials?  If so, you now have more options for your exams.  Starting on 15 September 2014 there are now electives for your MCSA certification.

There are now 2 required exams and a choice of 1 elective from a list of 4 exams to fulfill your SLQ Server 2012 MCSA certification requirements.

Required Exams: 

70-461 – Querying Microsoft SQL Server 2012: Objectives.

70-462 – Administering Microsoft SQL Server 2012 Databases: Objectives.

Elective Exams:  Pass one of the following to fulfill requirements.

70-411 – Administering Windows Server 2012: Objectives.

70-412 – Configuring Advanced Windows Server Services: Objectives.

70-463 – Implementing a Data Warehouse with Microsoft SQL Server 2012: Objectives.

70-483 – Programming with C#: Objectives.

 

Now you have more options open to you depending on your career path for certification.

Until next time, RIDE SAFE!

Rick Trader

Windows Server Instructor – Interface Technical Training 

Phoenix, AZ

The post Microsoft announces changes to SQL Server 2012 MCSA Certification appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/microsoft-announces-changes-sql-server-2012-mcsa-certification/feed/ 0
How to Display Blanks as Zeros in a SSRS Report https://www.interfacett.com/blogs/display-blanks-zeros-ssrs-report/ https://www.interfacett.com/blogs/display-blanks-zeros-ssrs-report/#comments Wed, 12 Nov 2014 16:51:14 +0000 http://www.interfacett.com/blogs/?p=?p=19432 Some of the cells in this SSRS matrix report are blank: To display zeros instead, we will use two functions: 1. [crayon-594b5b0fe378b260147706/] 2. [crayon-594b5b0fe3792964054136/]   In the design of the matrix, right-click on the textbox containing the values in question, then select Expression… to edit the expression underlying the textbox. Type the following expression in … Continue reading How to Display Blanks as Zeros in a SSRS Report

The post How to Display Blanks as Zeros in a SSRS Report appeared first on Interface Technical Training.

]]>
Some of the cells in this SSRS matrix report are blank:

001-How-to-Display-Blanks-as-Zeros-in-a-SSRS-Report

To display zeros instead, we will use two functions:

1.

IsNothing(<Val2Check>) returns a True of Val2Check is Null; otherwise, it returns False

2.

IIF(<Test>, <IfTrue>, <IfFalse>) return <IfTrue> if <Test> is True; otherwise, it returns <IfFalse>

 

In the design of the matrix, right-click on the textbox containing the values in question, then select Expression… to edit the expression underlying the textbox.

002-How-to-Display-Blanks-as-Zeros-in-a-SSRS-Report

Type the following expression in the Expression dialog:

003-How-to-Display-Blanks-as-Zeros-in-a-SSRS-Report

The expression says that if SUM(Fields!SubTotal.Value) is Null (the IsNothing() function that it is in returns a True if it is Null and a Fales if it isn’t), then a zero is returned by the expression; otherwise the SUM(Fields!SubTotal.Value) is used.

Click OK and preview the report again. Notice that zeros are now present in what used to be the blank cells.

004-How-to-Display-Blanks-as-Zeros-in-a-SSRS-Report

Enjoy!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

The post How to Display Blanks as Zeros in a SSRS Report appeared first on Interface Technical Training.

]]>
https://www.interfacett.com/blogs/display-blanks-zeros-ssrs-report/feed/ 1