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

Thursday, August 27, 2015

How to Upgrade SQL Server

Hello everyone,

In this blog, I will provide an outline of recommended tasks for the upgrade to SQL Server 2014. You can use this document to also upgrade to other versions.

To ensure a successful upgrade of your SQL Server to a new version, we need to review the following areas

Pre Work – Before you start
Data Loads – Getting your data loaded
Post Work – Finalize the environment

Pre Work – Before you Start

1. Hardware and Software Requirements for Installing SQL Server 2014
Review the minimum hardware and software requirements like editions

2. The SQL Server 2014 Upgrade Advisor tool
Analyses the configuration and recommends changes that need to be made

3. Review Breaking Changes 
New changes to SQL Server may break applications, scripts and/or functions that are bases on earlier versions of SQL Server

4. Review Behavioral Changes 
Behavior changes affect how features work and/or interact in the new versions

5. Review Release Notes
These notes describes the known issues with current version and should be reviewed before installation

6. Document all your findings
Record what you have learned. Update this document as you go along with the upgrade

7. Database Instant File Initialization      
Turn on this feature in the OS to help speed up the creation of databases

8. Start the installation of SQL Server
Ensure that you install the latest service packs and review cumulative patches

Data Loads – Getting your Data Loaded

1. When creating a new database(s) place data files, partitions and logs on to different disk 

2. Create multiple TempDB files on to different disks (use SSD drives)

3. Create an automated backup job

  • Back up all databases (include system and empty databases)
  • Verify that backup locations are correct
  • Use built in compression

4. Load user database data by restoring from ** latest full ** backups

5. Compatibility level. Ensure that the restored databases are set to compatibility level of new installation. If not set may result in possible issues and you won't be able to take advantage of the new features

  • Compatibility level for 2014  is 120
  • Compatibility level for 2012  is 110
  • Compatibility level for 2008 and  2008R2  is 100  
  • Compatibility level for 2005 is 90

6.  Recovery Model. Document the current recovery models and ensure that the restored database are set to the same

7. Database Ownership. Change the ownership of databases once they are restored to “sa”

8. Collation of all User databases. Review the collation setting for all databases are set correctly

Post Work – Finalize the Environment

1. DBCC CHECKDB WITH DATA_PURITY 
Causes DBCC CHECKDB to check the database for column values that are not valid or out-of-range
Execute this check on “all” databases

     DBCC CHECKDB WITH DATA_PURITY;

2. DBCC UPDATEUSAGE
Reports and corrects pages and row count inaccuracies in the catalog views. These inaccuracies may cause incorrect space usage reports returned by the sp_spaceused system stored procedure.
Execute this check on “all” databases

    DBCC UPDATEUSAGE(db_name);

3. Update Statistics
    Ensure you update statistics on all your databases

            USE db_name;
            GO
            EXEC sp_MSforeachtable @command1='UPDATE STATISTICS ? WITH FULLSCAN';


4. Refresh all Views
    Use sp_refreshview command

5. Perform backups on “all” databases, yes again!

6. Check your compatibility levels

7. Update your finding document

8. Script out your logins from source and apply to new SQL Server.  Also check for orphan logins

9. Script out and recreate link servers, SQL jobs, SSIS packages, SSAS and SSRS and any other objects that have been missed

10. Automate Backup Databases
Perform full database backups often and create automated backup jobs

11. Review Error Logs
Ensure your error logs are clean before using SQL Server.
https://msdn.microsoft.com/en-us/library/ms187109.aspx

Wednesday, April 22, 2015

SQL Server Management Studios (SSMS) Not Working Properly Exception from HRESULT: 0X8002801D Type_E_LIBNOTREGISTERED


Hello all,

I have found the issue and fix to the problem I've had experiencing with SQL Server Management Studios not working on a server. 


Issue: SQL Server Management Studios (SSMS) does not work properly
           and you get the following error:

 Exception from HRESULT: 0X8002801D Type_E_LIBNOTREGISTERED

Resolution:

First check if the following is in place.

1.  Run REGEDIT
2.  Expand - HKEY_CLASSES_ROOT
3.  Expand - TypeLib
4.  Expand - (91A74EB0-EFA0-482B-B43C-35CFC74B275F)
5.  Expand - a.0
6.  You should see the following keys
        0
        FLAGS
        HELPDIR
7.  Expand - the key called 0 (zero)
8.  Expand - win32
9.  Right click on (Default)
10. You now should see the following:  
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\dteproperties.tlb

Next if the steps 6 - 10 are missing, create the keys as above and restart SSMS.

If the error still continues then check the path of the "dteproperties.tlb" and modify the above with the proper path

The issues is now resolved.


Thanks,

Rudy

Monday, February 23, 2015

Quick SQL Server Configuration Summary Report

Hello everyone,


I have written this script to detect and display a quick summary of your SQL Server installation/environment. 

Download this (updated March 30, 2015) script here Detail Configuration Script

To view the report, open the script in SSMS and execute.There are temp tables created and dropped at end of execution.

Here is a list of information produced in the reported.

Display SQL Server name\Instance name
Display Installation Date
Display Machine Name       
Display Instance Name
Display Edition and BIT Level
Display Production Service Pack Level       
Display Production Name          
Display Production Version
Display Logical CPU Count
Display Maximum Memory (Megabytes)
Display Minimum Memory (Megabytes)
Display IP Address
Display Port Number
Display Default Domain Name
Display Service Account name
Display Clustered Status
Display Kerberos
Display Security Mode
Display Audit Level
Display User Mode
Display Collation Type
Display SQL Server Errorlog Location
Display SQL Server Default Trace Location
Display Number of Link Servers
Display SysAdmin Members
Display ServerAdmin Members
Display Configuration setting
Display code that automatically executes on startup
Display SQL Service Status
Display Location of Database files
Display Link Servers
Display Database Collation type
Display Database Hard Drive Space Available
Display Database Information
Display Database Backup Information
Display SQL Job Status
Display SQL Mail Information
Display Database Mirroring Status
Display Database Log Shipping Status
Display Report Server (SSRS) Reports Information

Please execute on your test/development environment and verify results. 
I will be adding more to this script in the future so watch for updates. 

Please let me know you comments.

Thanks,

Rudy 

Tuesday, January 13, 2015

Auto Generating of Service Principal Name (SPN) Commands

Hello All,

Have you had to use Kerberos authentication and needed to create the commands for the Service Principal Name (SPN)? Then the script in this blog will help. Execute the script on the SQL Server with SQL Server Reporting Services (SSRS) and it will automatically generate the commands needed. 

If you need more details on Kerberos have a look at Rob Carrol blog. It is very good and covers how to enable Kerberos authentication for reporting services. Here is his link.
http://blogs.technet.com/b/rob/archive/2011/11/23/enabling-kerberos-authentication-for-reporting-services.aspx

Now on to my script.

First, load this script on to your server (please verify on test servers) and execute. It only creates temp tables, does not write anything to SQL Server and the temp tables are deleted once executed.

The script will automatically detects the SQL Server settings

******** Settings that have been automatically detected **************

Result for detection of SQL Server name --> SrvName
Result for detection of Service Account name -->MyDomain\svcAccount
Result for detection of Port Number --> 1433
Result for detection of default Domain Name --> MyDomain
Result for detection of cluster --> SQL Server is not clustered
Result for detection of Kerberos --> TCP is using Kerberos
Result for detection of IP Address --> 192.168.54.1


Next, the script will take the information found and create the SETSPN commands 


cls
echo '*** Automatic SQL Server Service Principal Name (SPN) ***'
echo ' '
echo 'Setting SQL Server Database SPN...please wait'
echo ' '
  
SetSPN -s "MSSQLSvc/SQLServerName:1433" "MyDomain\svcAccount"
SetSPN -s "MSSQLSvc/SrvName.MyDomain.com:1433" "MyDomain\svcAccount"


echo ' '
echo 'Setting SQL Server Reporting Services SPN...please wait'
echo ' '

SetSPN -s "http/SrvName" "MyDomain\svcAccount"
SetSPN -s "http/SrvName.MyDomain.com" "MyDomain\svcAccount"


echo ' '
echo 'Setting SQL Server Analysis Services SPN...please wait'
echo ' '

SetSPN -s "msolapsvc.3/SrvName" "MyDomain\svcAccount"
SetSPN -s "msolapsvc.3/SrvName.MyDomain.com" "MyDomain\svcAccount"

echo ' '
SetSPN -l MyDomain\svcAccount"
echo ' '

           ==> Auto SPN generation is now complete <==

Finally, copy the SetSPN statements and execute then with a Domain Admin account.  Verify that the account "MyDomain\svcAccount" has the following check on "Trust this user for delegation to any service [Kerberos only]

Note that once the SetSPN command is executed it may take several hours (once mine took approx. 8) before it takes effect.

Here is the link for my script
https://drive.google.com/file/d/0B07PMQYOhF2DMEJMcnpGVDg3eFE/view?usp=sharing

Thanks,

Rudy


Thursday, January 8, 2015

SQL Server Performance Survival Guide

Hello and Happy New Year!

Today's blog is a link to the Microsoft Tech Net site that has an excellent guide regarding SQL Server performance. It is worth a look and a place in your browser's bookmarks.

http://social.technet.microsoft.com/wiki/contents/articles/5957.sql-server-performance-survival-guide.aspx

Below is the table of contents

Learning about Troubleshooting SQL Server Performance
Transaction Processing (OLTP)
Data Warehouse Performance
Troubleshooting Hardware Issues
Monitoring and Performance Tools
Performance Tips and Tricks
Performance Topics in SQL Server Books Online
Getting Advice and Guidance
SQL Server Customer Advisory Team
Community Resources
SQL Server Performance Blogs
SQL Server Performance Forums
SQL Server Resource Centers
SQL Server Performance Workshops
SQL Server Social Networking
Twitter
SQL Server Performance on Facebook
SQL Server Performance Books

Hope you find this useful,

Rudy