Posted by Barac in SQL Monitoring, SQL Server
on Jun 24th, 2018 | 0 comments
Recently I had a customer with a really slow query execution and a case of large page splits number on the temporary database. In this example, I tried to replicate the similar issue on my local SQL instance using StackOverflow database. You can download this StackOverflow DB from Brent Ozar web page, just follow the instructions How to Download the Stack Overflow Database via BitTorrent Firstly I created an Extended Event session to follow up if the page splits occur. DBCC DROPCLEANBUFFERS CREATE EVENT SESSION [PageSplits] ON SERVER...
Posted by Barac in SQL Server
on May 30th, 2018 | 0 comments
Recently we had really nice meetup gathering here in Auckland. Was a beautiful evening, there were 20 people talking about SQL server, was perfect. One of the topics was “Merge Join Operator” For this demo I used SQL Server 2014 Developer Edition. As a database I used StackOverflow, you can download this DB from Brent Ozar web page, just follow the instructions How to Download the Stack Overflow Database via BitTorrent In this example I will use two tables Badges (25 million rows) and Users (8 million rows) and I will join them on Userid...
Posted by Barac in SQL Server, SQL Tips and Tricks
on May 4th, 2018 | 1 comment
This is example of long running queries of database within email alert, we already had example how you can use sp_send_dbmail stored procedure from msdb database to send backup size email daily, and how to send missing indexes report via email. This is just another use case of sp_send_dbmail stored procedure. I used following arguments to achieve this @profile_name (name of an existing Database Mail profile, type sysname, default NULL), If you are not sure about your profile account use the following script, it shows all the accounts for all...
Posted by Barac in SQL Server
on Apr 21st, 2018 | 0 comments
Recently we had really nice meetup gathering here in Auckland. Was a beautiful evening, there were 20 people talking about SQL server, was perfect. One of the topics was “Bad estimates and Memory Grant Warning” For this demo I used SQL Server 2014 Developer Edition. As a database I used StackOverflow, you can download this DB from Brent Ozar web page, just follow the instructions How to Download the Stack Overflow Database via BitTorrent In the previous post we talked about using string function in the WHERE clause and bad estimates...
Posted by Barac in SQL Server
on Apr 19th, 2018 | 2 comments
Recently we had really nice meetup gathering here in Auckland NZ. Was a beautiful evening, there were 20 people talking about SQL server, was perfect. One of the topics was “String functions in the where clause and bad estimates” For this demo I used SQL Server 2014 Developer Edition. As a database I used StackOverflow, you can download this DB from Brent Ozar web page, just follow the instructions How to Download the Stack Overflow Database via BitTorrent Using string function in the WHERE clause can cause bad estimates. I...
Posted by Barac in SQL Server, SQL Tips and Tricks
on Mar 13th, 2018 | 0 comments
Several time, using different SQL Server versions I end up having a problem with initializing secondary database using SSMS transaction log shipping GUI (mainly with large databases). I got errors similar to: System.Data.SqlClient.SqlError: Cannot open backup device ‘\\network_path\trnls\db01.bak’. Operating system error 5(Access is denied.). (Microsoft.SqlServer.Smo) Indicating that you don not have enough permissions. Even after I confirmed all permissions are OK, and I already have another DB using same...
Posted by Barac in Powershell, SQL Server
on Mar 1st, 2018 | 2 comments
Script Download: The script with usage example is available for download from https://gallery.technet.microsoft.com/Use-PowerShell-to-check-05ca591f Summary: Check SQL Server Version and the current patch level for all servers you specified. As well check latest patches/updates available for installed SQL Server version and send email with results. Description: SQL Server Instance Update Status PowerShell script which can be invoked remotely from another PC trough the command line, with PowerShell or executed remotely through task scheduler...
Posted by Barac in SQL Server
on Mar 1st, 2018 | 0 comments
This is one simple example how you can use sp_send_dbmail stored procedure from msdb database to send DB backup size daily. I used folowing arguments to achive this: @profile_name (name of an existing Database Mail profile, type sysname, default NULL), @recipients (Is a semicolon-delimited list of e-mail addresses to send the message to, varchar(max)), @body (Is the body of the e-mail message, nvarchar(max)), @subject (Is the subject of the e-mail message, nvarchar(255)), @body_format (Is the format of the message body, varchar(20)) More...
Posted by Barac in SQL Server, SQL Tips and Tricks
on Feb 20th, 2018 | 0 comments
Most of the time it is very easy to remove secondary server from your log shipping configuration. But what happens if secondary server is not available. We had this case on one of our testing environment, we had secondary server on the cloud and after a month server lease expired. When we tried to remove that server from our log shipping configuration we end up with following errors. Error details As you can see from error details SQL Server Management Studio could not delete the Secondary server ‘SQLNODE2’....
Posted by Barac in SQL Server, SQL Tips and Tricks
on Feb 15th, 2018 | 1 comment
This is example of missing indexes of database within email alert, we already had example how you can use sp_send_dbmail stored procedures from msdb database to send backup size email daily, and this example is just to show use case with different scripts. I used following arguments to achieve this @profile_name (name of an existing Database Mail profile, type sysname, default NULL), @recipients (Is a semicolon-delimited list of e-mail addresses to send the message to, varchar(max)), @body (Is the body of the e-mail message, nvarchar(max)),...