About Me - Who is DR DBA?

Hello. My name is Rudy Panigas and I am a Production Senior Microsoft SQL Server Database Administrator (DBA) with over 14 years of experience. Have published articles with SQL Central, am a leader for the my local PASS chapter in Toronto (TORPASS) and love to automate anything SQL including disaster recovery. I created this blog to share my views, knowledge and to discuss Microsoft SQL server in order to help out others in this field. Please test these scripts before using. I do not warranty and do not take any responsibility for it, its misuse or output it creates. You can reach me at this email address: sqlsurgeon@outlook.com

Monday, December 22, 2014

SSRS Subscription Status

Need to see the status of a report subscription in SSRS? Well now you can. This script, see download link below, will provide the following details.


  • Event type
  • Executed by
  • Inactive or active 
  • Last status
  • Description
  • Last run status
  • Delivery extension
  • Date modified

https://drive.google.com/file/d/0B07PMQYOhF2DWWhER19jazFEdk0/view?usp=sharing

Enjoy!

View User Access to your Reports in SSRS

How to see what access users have to your reports in SQL Server Reporting Service (SSRS)? Well now you can view the access with the following script, download it here 

https://drive.google.com/file/d/0B07PMQYOhF2DWWhER19jazFEdk0/view?usp=sharing

The script will show the following information


  • Role name
  • User name
  • Path of report
  • Report name
  • Catalog type
  • Description
Hope you find it useful.

Enjoy

Friday, December 19, 2014

Memory Usage by All Databases

Hello,

Do you know how much memory your databases are using and how much free memory you SQL Server has? Try this script below. 

The output will show the following:

  • List all the databases with how much memory they are using
  • Total usage for all databases
  • Max memory set in SQL Server
  • Memory available by subtracting the 2 values from above.
Enjoy!


DECLARE 
@TotalUsedByDatabases NUMERIC
,@TotalMAXMemorySQLSrv NUMERIC

SELECT
 isnull(db_name(database_id), 'resourcedb') [dbname]
, CAST(COUNT(row_count)/128.0 as decimal(10,2)) [size]
INTO #RAM
FROM sys.dm_os_buffer_descriptors
GROUP BY database_id

SELECT dbname [Name of Databases], size [Memory Usage in MB] FROM #RAM

SET @TotalUsedByDatabases = (SELECT SUM(size) FROM #RAM);
SET @TotalMAXMemorySQLSrv = (SELECT CAST(value_in_use as NUMERIC) 
FROM sys.configurations 
WHERE name LIKE 'max server memory%');

SELECT @TotalUsedByDatabases [Total Memory used by Databases in MB]
, @TotalMAXMemorySQLSrv  [Max Memory Allocated to SQL Server in MB]
, @TotalMAXMemorySQLSrv - @TotalUsedByDatabases [  ** Memory Available ** in MB]


DROP TABLE #RAM;

Tuesday, November 25, 2014

SQL Server 2014 Checklist for Performance

Hello once again :)

Over time and discussing with other DBAs, I have compiled a checklist for performance. Here are some areas and comments for each. 

SQL Server 2014 Checklist for Performance

- Test your changes on your test servers
- Make changes incrementally - small change at a time
- Use 64 bit, even on a laptop

Memory
Set MIN and MAX values for memory. Max setting use script to calculate
Enable Optimize for Ad Hoc Workloads

CPU
Set "Cost Threshold for Parallelism" = OLTP = 45 and Reporting = 25. Default is 5 which is to low

Set "Max Degree of Parallelism"  leave it on after you have changed the cost threshold. 

Set NUMA = number of physical processors, not cores, is a good place to start

Disk
TEMPDB on separate disks,

Set TEMPDB data and logs onto separate disks

Use multiple files wtih equal sizes, not equal to the number of processors

Use index compression

More disks is better but limited to the number of controllers

Statistics
Enable AUTO_CREATE and AUTO_UPDATE

Make plans to manual updates on statistics with full scans

Defragment Indexes
Number of pages matter,defrag below 300-500 pages

Cannot defrag below 8 pages

Defragment indexes with less then 50% fragmentation and rebuilt index if higher than 50%

DO NOT USE 
Disable AUTO_CLOSE

Disable AUTO_SHRINK

DO NOT use Profiler GUI, use extended events, even in SQL 2008

Create server side trace using T-SQL scripts. Can you use the GUI to create but execute via T-SQL

Database Design
Separate log and data files onto separate disks

Use multiple file groups even on a single disk

Turn off AUTO_GROW (depends). If not, use fixed growth, not percentage. Do not leave defaults in place

Normalize the data as it benefits performance

Enforce constraints, have foreign keys, primary keys, unique indexes

Use narrow indexes, when possible

Indexes work better on integers - performance better

Don't create too many indexes (depends)

Rebuilt cluster indexes 

Coding
Return only use data you need

Use stored procedures or parameterized queries

Avoid cursors, WHILE, LOOP

Quality all object names

Avoid using sp_* stored procedure names

Avoid functions on columns and LIKE command

SET NOCOUNT ON

Don't nest the views and join views to views

Don't use NOLOCK 

Avoid recompiling execution plans

Use table variables instead of temp tables

Multi statement table valued functions are very bad!

Let me know if you have any additional checks to add

Thanks,

Rudy

Are you Ready for a New SQL Server Version?

Hello again,

As you are aware Microsoft like to provide DBAs and developers with more work every two years. So, are you ready for a new version of SQL Server and all the migration that goes along with it?

If you are not upgrading then you're lucky, for now. Most DBA/Developers I know are in the middle of upgrading to SQL Server 2012/2014.

If you are upgrading, then I would highly recommend reading an article from Michael J. Swart called "Developers, Ready for a New SQL Server Version?" 

http://michaeljswart.com/2014/11/devs_ready_for_a_new_version/

It's an excellent articles for developers and DBAs.

Thanks,

Rudy

Tuesday, May 20, 2014

Antivirus SQL Server Recommended Setting

Hello Again,

This blog will show the Microsoft Support recommended antivirus (AV) setting for SQL Server. Each version of SQL Server will be listed below with different setting for each version. Below are the directories and file-name extensions that must be exclude from AV scanning.

Common AV Settings for all versions of SQL Server
Regardless of the version of SQL Sever the exclusion below will apply.
SQL Server data files
These files usually have one of the following file-name extensions:

  • .mdf
  • .ldf
  • .ndf

SQL Server backup files
These files frequently have one of the following file-name extensions:

  • .bak
  • .trn

Full-Text catalog files
Default instance: Program Files\Microsoft SQL Server\MSSQL\FTDATA
Named instance: Program Files\Microsoft SQL Server\MSSQL$instancename\FTDATA

Trace files

  • .trc
These files usually have the .trc file-name extension. These files can be generated either when you configure profiler tracing manually or when you enable C2 auditing.

SQL audit files (for SQL Server 2008 or later versions)

  • .sqlaudit
These files have the .sqlaudit file-name extension. For more information, see the following topic in SQL Server Books Online

SQL query files

  • .sql
These files typically have the .sql file-name extension and contain Transact-SQL statements.
The directory that holds Analysis Services data
Default location C:\Program Files\Microsoft SQL Server\MSSQL.X\OLAP\Data
For more specifics contact the DBA team for actual locations as this can change based on the installation and requirements.

Clustering Setting
Exclude the following locations from being scanned

  • Quorum drive letter
  • C:\Windows\Cluster
  • DTC drive letter

SQL Server 2012
Apply the recommendation mentioned in the Common AV Settings for all versions of SQL Server section and the exclusions below.
%ProgramFiles%\Microsoft SQL Server\MSSQL11.<Instance Name>\MSSQL\Binn\SQLServr.exe
%ProgramFiles%\Microsoft SQL Server\MSRS11.<InstanceName>\ReportingServices\ReportServer
\Bin\ReportingServicesService.exe
%ProgramFiles%\Microsoft SQL Server\MSAS11.<Instance Name>\OLAP\Bin\MSMDSrv.exe

SQL Server 2008 R2
Apply the recommendation mentioned in the Common AV Settings for all versions of SQL Server section and the exclusions below.
%ProgramFiles%\Microsoft SQL Server\MSSQL10_50.<Instance Name>\MSSQL\Binn\SQLServr.exe      %ProgramFiles%\Microsoft SQL Server\MSSQL10_50.<Instance Name>\ReportingServices\ReportServer
\Bin\ReportingServicesService.exe
%ProgramFiles%\Microsoft SQL Server\MSSQL10_50.<Instance Name>\OLAP\Bin\MSMDSrv.exe

SQL Server 2008
Apply the recommendation mentioned in the Common AV Settings for all versions of SQL Server section and the exclusions below.
%ProgramFiles%\Microsoft SQL Server\MSSQL10.<Instance Name>\MSSQL\Binn\SQLServr.exe
%ProgramFiles%\Microsoft SQL Server\MSSQL10.<Instance Name>\ReportingServices\ReportServer
\Bin\ReportingServicesService.exe
%ProgramFiles%\Microsoft SQL Server\MSSQL10.<Instance Name>\OLAP\Bin\MSMDSrv.exe

SQL Server 2005
Apply the recommendation mentioned in the Common AV Settings for all versions of SQL Server section and the exclusions below.
%ProgramFiles%\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\SQLServr.exe
%ProgramFiles%\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\Bin\ReportingServicesService.exe
%ProgramFiles%\Microsoft SQL Server\MSSQL.2\OLAP\Bin\MSMDSrv.exe

Please let me know if you find any additional information I should add.

Thanks,

Wednesday, March 26, 2014

SQL Server 2012 on a Windows 2012R2 Cluster – Things to watch out for

While performing a new installation of SQL Server 2012 on a Windows 2012R2 cluster, I learned a few things along the way and I want to share them with you.

There are 3 main area to watch out when building the cluster and SQL Server

1.      Integration Services (SSIS) is not cluster aware. You can get SSIS working in the cluster. However, if you have a SSIS package that is executing and the cluster fails over (from active to passive node) the SSIS package will not continue to execute. In fact you have to restart the SSIS package execution. Therefore you need to build some logic in you package to detect if the SSIS package execution was completed or not and if not, who to roll back the changes and re execute it. There is also a fix to allow remote connection to SSIS which can break too

2.      Reporting Services (SSRS) will not start after applying patches. It appears that the patch can/does break SSRS but it’s an easy fix 

3.  Always On Availability Groups does not work between clusters. That is, if you have a cluster (say 2 nodes) and you want to replicate with Always On Availability Groups to another cluster (again say a 2 node cluster), this will not work! There is no documentation from Microsoft support about this. So be aware of this limitation

Below are the links that help with the issues notes above and others I found useful when building a Windows 2012R2 cluster and SQL Server 2012.

Integration Services (SSIS) in a Cluster is not Cluster Aware

Configure the Integration Services Service as a Cluster Resource

Grant Access to the Integration Services Service

Connect to a Remote Integration Services Server

Cannot Start SQL Server Reporting Services after applying an update

Before Installing Failover Clustering

SQL Server Failover Cluster Installation

Create a New SQL Server Failover Cluster (Setup)

Error during Installation of an SQL Server Failover Cluster Instance

Please let me know if you find any other useful information and/or links in this topic.

Thanks and enjoy.


Rudy

Thursday, January 23, 2014

My other blog at DELL Software - New

Hello all,

Today I have another blog which is with DELL Software and will be covering more topics. See below for link.