BitLocker – Configuration – Error – “Unable to find the Reporting Services instance name”

Background

Recently we ran into an “ha ha” moment installing Microsoft BitLocker.

 

BitLocker Administration and Monitoring

Configuring Reports

Here is the “Configuring Reports” window.

ConfigureReports_20180720_1008AM

Error

Error Image

unableToFindTheReportingServicesInstanceNameMSSQLServer

Error Text

Unable to find the Reporting Services instance name <server-name>\MSSQLServer

Trouble Shooting

Reporting Services Configuration Tool ( RSConfigTool )

Launched SQL Server Reporting Services Configuration Tool ( RSConfigTool).

RSConfig_ReportServerStatus_20180720_1033AM.png

Ensured that the service is running and noted the Instance ID.

The Instance ID is SSRS.

Remediation

BitLocker Administration and Monitoring

Configuring Reports

For the instance name, please note the instance name recorded earlier.

That instance name is SSRS.

Configuration SSRSDB.20180720_1041AM

 

 

SQL Server – Network – Get TCP Ports

Background

Get network ports that the current SQL Server Instance is using.

Outline

There are some pathways to getting the SQL Server Network Ports:

  1. sys.dm_server_registry
    • SQL Server Version
      • v2008

Code

sys.dm_server_registry

SQL


select 

          tblDSR.registry_key
        , tblDSR.value_name
        , tblDSR.value_data
        , [userOrAdmin]
            = case
                when (tblDSR.registry_key like '%AdminConnection%') then 'Admin'
                else 'User'
              end

from   sys.dm_server_registry tblDSR

/*
	Database Engine - MSSQLServer
*/
where
       (

            (
                ( tblDSR.registry_key like '%\MSSQLServer\%' )
			)
        )

/*
	Filter in TCP Ports
*/
and
       (

            (
                tblDSR.value_name in
                    (
                          'TcpDynamicPorts'
                        , 'TcpPort'
                    )
            )

        )

/*
    Filter out \IP1 thru \IP4
        HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IP1
        HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IP2
        HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IP3
        HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IP4
*/
and
       (
            ( tblDSR.registry_key not like '%\IP_')
        )

/*
    Filter out empty data
*/
and
        (

                ( tblDSR.value_data is not null )
            and ( tblDSR.value_data != '' )
            and ( tblDSR.value_data != '0' )
        )

Output

Output – Default Instance

sysDOTdm_server_registry__Default__20180606_0258PM.png

Output – Named Instance

sysDOTdm_server_registry__20180606_0239PM.png

Explanation

  1. Registry Key
    • Please close out your eyes to the AdminConnection; unless you are trying to connect to the Admin Port
    • Most people will be using the regular user default port

References

  1. Microsoft
    • Docs / SQL / Relational databases / System dynamic management views
      • sys.dm_server_registy

SQL Server :- sys.dm_db_stats_histogram

Background

As always pressed to grasp something that my very little mind has not been able to understand.

And, that is how to read Statistics Histogram.

SQL

Thankfully Microsoft is always furnishing us with new pathways towards understanding.

sys.dm_db_stats_histogram

Today that way for me is via sys.dm_db_stats_histogram.

The DMV was introduced in v2016 SP1.

Syntax

It takes the ObjectID and Statistics ID and assumes that you are in the contextual database.


select *

from  sys.dm_db_stats_histogram
(
       @objectID
     , @statisticsID
)

Returned Record Set

We will make heavy use of the word range and define it as the preceding row’s range_high_key and our current row’s range_high_key.

Column Meaning Datatype
step_number Step Number from 1 to Maximum of 200 smallint
range_high_key Highest for specific step sql_variant ( Depends on data-type of first stats column)
range_rows Number of records in range real
equal_rows Number of rows that exactly match range_high_key real
distinct_range_rows Number of distinct records in range bigint
average_range_rows Number of records in range / Number of distinct records in range real

Usage


use [DBLab]
go

declare @table sysname
declare @objectID int
declare @index sysname
declare @indexID smallint

set @table = '[dbo].[sales]'
set @index = 'INDX_SalesDate'

set @objectID = object_id(@table)

select

      @indexID = index_id

from  sys.indexes tblSI

where  tblSI.object_id = @objectID

and    tblSI.[name] = @index

DBCC SHOW_STATISTICS
(
       @table
     , @index
)
with histogram

;

select
         [object]
         =
             quotename(tblSS.[name])
           + '.'
           + quotename(tblSO.[name])

       , [stat]
          = tblSS2.[name]

       , tblSH.step_number
       , tblSH.range_high_key
       , tblSH.range_rows
       , tblSH.equal_rows
       , tblSH.distinct_range_rows
       , tblSH.average_range_rows

from   sys.dm_db_stats_histogram
       (
           @objectID
         , @indexID
       ) tblSH

inner join sys.objects tblSO
   on tblSH.object_id = tblSO.object_id

inner join sys.schemas tblSS
   on tblSO.schema_id = tblSS.schema_id

inner join sys.stats tblSS2
   on  tblSH.object_id = tblSS2.object_id
   and tblSH.stats_id = tblSS2.stats_id

 

Output

sysDOTdm_db_stats_histogram_20180530_0642PM

Workshop

Let us pick up on the second row and see if we can understand what each column means.

Image

sysDOTdm_db_stats_histogram_20180530_0647PM

Explanation

  1. Step Number
    • Definition
      • There are at most 200 steps in a SQL Server Statistics Histogram
    • Step Number :- 1
      • Low Bar
    • Step Number :- 200 or last row
      • High Bar
  2. Range High Key
    • Definition
      • This is the maximum value of the current row’s range
    • Step Number :- 2
      • 1900-01-01 16:17:00.000
  3. Range Rows
    • Definition
      • This is the number of rows between the previous row’s max value and the current row’s max value
    • Step Number :- 2
    • 1016
  4. Equal Rows
    • Definition
      • This is the number of rows that exactly match this row
    • Step Number :- 2
    • 5
  5.  Distinct Range Rows
    • Definition
      • This is the number of rows that have distinct values for the current range
    • Step Number :- 2
    • 625
  6. Average Range Rows
    • Definition
      • Number of rows / number of rows that have distinct values for the current range
    • Step Number :- 2
    • 1.6256

Collaborative Query

We will instruct a full update statistics scan against our test table and issue a query against the first column of our statistics.

We will then compare the result set against what is listed in our histogram.

Query


set nocount on;
go

declare @dateRangeBegin datetime
declare @dateRangeEnd   datetime

set @dateRangeBegin = '1900-01-01 00:00:00.000'
set @dateRangeEnd = '1900-01-01 16:17:00.000'

select
         [numberofRows]
            = count(*)

       , [numberofEqualRows]
        = sum(
                case
                    when clock_time = @dateRangeEnd then 1
                    else 0
                    end
             )

       , [numberofDistinctRows]
            = count(distinct [clock_time])

       , [averageDistinctRows]
            = cast
                (
                    (
                          count(*) *1.00
                        / NULLIF
			(
			    count(distinct clock_time) * 1.00
			   , 0
			)
                    )
                    as decimal(20, 6)
                )

from   [dbo].[sales] tblI

where  tblI.clock_time
            between @dateRangeBegin and @dateRangeEnd

Output

sysDOTdm_db_stats_histogram_20180530_0704PM

Explanation

  1. Number of Rows
    select count(*) against table
    
  2. Number of Equal Rows
    sum
        (
           case
              when clock_time = @dateRangeEnd then 1
              else 0
             end
        )
    
  3. Number of Distinct Rows
    count(distinct [clock_time])
    
  4. Average Range Rows
    cast
    (
    	(
    		  count(*) *1.00
    		/ count(distinct clock_time) * 1.00
    	)
    	as decimal(20, 6)
    )
    

References

  1. Docs > SQL >Relational databases > System dynamic management views
    • sys.dm_db_stats_histogram (Transact-SQL)
      Link

Transact SQL – STRING_AGG

Background

In our post on MySQL – Information_schema.statistics we spoke glowingly of the GROUP_CONCAT Function.

I really could not find a way around using it in MySQL.

I ran into some difficulties using it and as with problems one just googles for workarounds.

BTW, the MySQL post is here.

SQL Server

Introduction

It seems that in version 2017, MSFT played catch up.

And, added a similar function.

String_Agg

Code


select
        [object]
            = quoteName(tblSS.[name])
              + '.'
              + quoteName(tblSO.[name])

        , [indexID]
            = tblSI.[index_id]

        , [index]
            = tblSI.[name]

        , [indexType]
            = tblSI.[type_desc]

        , [columnList]
            = 
                STRING_AGG 
                (
                      concat
                      (
                          tblSC.[name]
                        , ''
                      )	

                    , ', '
                ) 
                WITHIN GROUP 
                (
                    ORDER BY 
                        tblSIC.[key_ordinal]
                )
            

from   sys.schemas tblSS

inner join sys.objects tblSO

        on   tblSS.[schema_id] = tblSO.[schema_id]
 
inner join sys.indexes tblSI

        on   tblSO.[object_id] = tblSI.[object_id]

inner join sys.index_columns tblSIC

        on   tblSI.[object_id] = tblSIC.[object_id]
        and  tblSI.[index_id]  = tblSIC.[index_id]

inner join sys.columns tblSC

        on   tblSIC.[object_id] = tblSC.[object_id]
        and  tblSIC.column_id = tblSC.column_id

/*
    Skip MS Shipped Objects
*/
where tblSO.is_ms_shipped = 0

/*
    Exclude Included Columns
    Only Include actual Key Columns
*/
and   tblSIC.[key_ordinal] > 0

group by

                quoteName(tblSS.[name])
              + '.'
              + quoteName(tblSO.[name])

        , tblSI.[index_id]

        , tblSI.[name]

        , tblSI.[type_desc]

order by

                quoteName(tblSS.[name])
              + '.'
              + quoteName(tblSO.[name])

        , tblSI.[index_id]

        , tblSI.[name]



Output

 

Crediting

Crediting Dan M for asking the question.

And, Martin Smith for ably.

Simulating group_concat MySQL function in Microsoft SQL Server 2005?
Link

 

References

  1. Microsoft
    • String_Agg
    • sys.index_columns
  2. Stack Overflow
    • Simulating group_concat MySQL function in Microsoft SQL Server 2005?
      Link

SQL Server – Operator – Top – Top Expression (0)

Background

Earlier today I found myself pressing to make sure I had done right by a query.

 

Query Plan

Query Plan – 01

Here is the original query Plan

Image

queryPlan_computeScaler_HashMatch_20180517_1139AM [clipped]

Explanation

  1. I know that I don’t really want a Hash Match
    • Took care of the Hash Match by reducing the query from two tables to a single table
    • There are a few novel ways to do so, and will cover that later

 

Query Plan – 02

Here is the query Plan once we got rid of the secondary table

Image

queryPlan_computeScaler_HashMatch_20180517_1143AM [clipped]

 

Top ?

I was stuck at the Top Operator for a very long time

Explanation

  1. Rowcount
    • Do I have a set rowcount somewhere
    • Is my environment introducing a constraint for maximum number of records to “touch
    • Is my edition of SQL Server throttling performance
  2. Top
    • Do I have a top N clause somewhere

 

Operator – Top – Default

Overview

Here is what our Top Operators looks like when we do not have “set rowcount” set and we do not have an actual TOP Clause.

Image

Explanation

  1. Actual Number of Rows :- 65
  2. Output List :- sysschobjs.id & sysschobjs.nsid
  3. Top Expression :- (0)

 

Operator – Top – “Set rowcount”

Overview

What if we add an actual set rowcount

Image

 

Explanation

  1. Actual Number of Rows :- 2
  2. Output List :- sysschobjs.id & sysschobjs.nsid
  3. Top Expression :- (0)

Operator – Top – “Select TOP N”

Overview

Here is what we see when we add a “Top 1” Clause.

Image

Explanation

  1. Actual Number of Rows :- 1
  2. Output List :- sysschobjs.id & sysschobjs.nsid
  3. Top Expression :- (1)

 

Other Things

Overview

I was stuck and so tried other things; such as

  1. Newer version of SQL Server ; v2017 to be exact
  2. Took out the insert into and performed a simple select

Could not reproduce…

 

Craig Freedman ( MSFT )

Finally goggled on the right terms and read what Craig Freedman has to say.

The particular post that I will be quoting is:

ROWCOUNT Top
Link

  1. TOP Operator
    • If you’ve looked at any insert, update, or delete plans, including those used in some of my posts, you’ve probably noticed that nearly all such plans include a top operator.
  2. SET ROWCOUNT
    •  It is a ROWCOUNT top. It is used to implement SET ROWCOUNT functionality.
  3. Why doesn’t SQL Server add a ROWCOUNT top to select statements?
    • SQL Server implements SET ROWCOUNT for select statements by simply counting and returning the correct number of rows from the root of the plan.  Although this strategy might work for a really trivial update plan such as the one above, it would not work for more complex update plans.  For instance, if we add a unique index to our table, the update plan becomes substantially more complex
  4. Placement
    • By placing the ROWCOUNT top above the table scan, the optimizer can ensure that the server updates exactly the correct number of rows regardless of the complexity of the remainder of the plan.

 

Martin Smith

The good thing about blogging and allowing comments is that people can come back and provide helpful feedback.

Here is one from Martin Smith:

Martin Smith
December 29, 2012 at 8:15 am

In 2012 it looks like this operator is only added to plans run under “SET ROWCOUNT” of other than zero. As far as I can discern it is added in to the set_options used as a plan cache key.

SQL Server Versions

Here are the versions of SQL Server where you will be able to reproduce the Top (0) Operator preceding data effecting operators :-

  1. 2005
  2. 2008-R2

Dedication

Thankfully I have a far better grasp courtesy of two able men, Craig Freedman & Martin Smith.

SQL Server – Querying for OS Version

Background

As SQL Server now runs on Linux it is likely a good idea to be able to determine the underlying OS that a specific instance is sitting on.

 

Choices

Here are some choices for determining a targeted SQL Instance OS Version :-

  1. @@version
  2. sys.dm_os_host_info
    • SQL Server Versions
      • v2017 and above

 

System Function

@@version

Syntax


select @@version

Output

Tabulated
@@version OS/Client OS/Server
 Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) – 14.0.3015.40 (X64)
Dec 22 2017 16:13:22
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Windows 10 Enterprise 2016 LTSB 10.0 <X64> (Build 14393: )
Windows 10
Microsoft SQL Server 2014 (SP2-CU7) (KB4032541) – 12.0.5556.0 (X64)
Aug 17 2017 12:07:38
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.3 (Build 14393: ) (Hypervisor)
Windows Server 2016
Microsoft SQL Server 2017 (RTM) – 14.0.1000.169 (X64)
Aug 22 2017 17:04:49
Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor)
Windows 8.1 Windows Server 2012 R2
Microsoft SQL Server 2014 – 12.0.4100.1 (X64)
Apr 20 2015 17:29:27
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2) (Hypervisor)
Windows Vista Windows Server 2008

 

Dynamic Management View

sys.dm_os_host_info

Syntax


SELECT 
          host_platform
	, host_distribution
	, host_release
	, host_service_pack_level
	, host_sku
	, os_language_version  

FROM sys.dm_os_host_info

;

Output

 

Summary

If you happen to be running SQL Server v2017, you will have not do to all the parsing involved with getting accurate data from @@version.

 

Addendum

Did a similar post here.

This was back in 2010.  And, that post is titled “MS SQL Server – Read OS Version“.

Windows NT 6.3

Unfortunately “Windows NT 6.3” is returned for the following OSes:

  1. Windows 2016
  2. Windows 2012

Prove

Windows Server 2016

SQL Server

master.dbo.xp_MSver
Image

Explanation
  1. Name :- WindowsVersion
  2. Internal Value :- 364118016
  3. Character Value :- 6.3 (14393)

 

WinOS

systeminfo
Image

Blogging

Blogging is an interesting option.

How much to reveal and how much to slay.

It all depends on what the original intent is.

Arguing for the sake of arguing is pointless.

 

References

  1. Microsoft
    • SQL Server
      • Docs > SQL > Relational databases > System dynamic management views
        • sys.dm_os_host_info ( Transact SQL )
          Link
      • Docs > SQL > T-SQL > Functions
        • @@version ( Transact SQL )
          Link
      • Docs / SQL / Relational databases / System stored procedures

SQL Server 2017 – Developer Edition – ISO

Background

Currently, I have SQL Server 2014 Developer Edition on my laptop.

Recently found out that since my machine is now Windows 10, I can have SQL Server 2017 Developer Edition.

 

Download ISO

Let us go download v2017 Developer Edition.

v2017 is available here.

Available

Image

Textual

  1. Free Trial Evaluation
  2. Developer edition
  3. Express edition

Developer Edition

If we click on the “Download now” button underneath the “Developer edition“, we will notice that the name of the file that will be availed is SQLServer2017-SSEI-Dev.exe.

Already have that file and it is a small file.

I don’t really want a small file, I want the full ISO.

 

Self-Prepare ISO

Download Bootstrap

To get a nice ISO, please process with downloading SQLServer2017-SSEI-Dev.exe.

 

Prepare ISO

Outline

  1. Select an installation type
  2. Specify SQL Server Installer download
    • Which package will you like to download
      • ISO
      • CAB
    • Click on the Browser folder button
      • Choose an existing folder or create a new folder
      • Click the OK button
    • Click the OK button
  3. Download Media

Screen shot

Select an Installation Type

 

Specify SQL Server Installer download

Browse Folder

Download Media

Download Successful

 

Installed

Once the files was packaged into a nice ISO, was able to install it.

 

Conclusion

So unfortunately, it appears that one cannot download v2017 as a nice offline ISO.

But, please do not let that overly deter you.

Go ahead and download SQLServer2017-SSEI-Dev.exe and run it.

You will be able to prepare an ISO through running that package.