SQL Server / Query Optimization / Memory Grant Warning / Excessive Grant

SQL Server / Query Optimization / Memory Grant Warning / Excessive Grant
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...
read more

SQL Server / Query Optimization / String functions in the WHERE clause and bad estimates

SQL Server / Query Optimization / String functions in the WHERE clause and bad estimates
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...
read more

SQL Server / Initialize Secondary Database / Generate a full backup of the primary database using SSMS transaction log shipping GUI issue

SQL Server / Initialize Secondary Database / Generate a full backup of the primary database using SSMS transaction log shipping GUI issue
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...
read more

PowerShell / SQL Server / Check SQL Server current Update Status and send Email Report

PowerShell / SQL Server / Check SQL Server current Update Status and send Email Report
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...
read more

SQL Server / DB Backup Size Last Month / Email Alert

SQL Server / DB Backup Size Last Month / Email Alert
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...
read more

SQL Server / SQL Server Management Studio could not delete the Secondary server / Secondary not available

SQL Server / SQL Server Management Studio could not delete the Secondary server / Secondary not available
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’....
read more

SQL Server / Missing Indexes Query / Email Alert

SQL Server / Missing Indexes Query / Email Alert
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)),...
read more

SQL Server / The target principal name is incorrect. Cannot generate SSPI context

SQL Server / The target principal name is incorrect. Cannot generate SSPI context
One of our old SQL servers was running under the local system context. Then we decided to change the account that the SQL service runs under, and we created domain service account with basic domain user permissions. Eventually, we end up with following error trying to access our SQL Server remotely.   SQL Server SPN Creation To run SQL Server service you can use Local System account, local user account or a domain user account. If you are using Local System account to run your SQL Service the SPN will be automatically registered. ...
read more

Microsoft SQL Server 2017 / RTM (14.0.1000.169)

Microsoft SQL Server 2017 / RTM (14.0.1000.169)
  SQL SERVER 2017 RTM Update Version: MSSQL 2017 RTM CU-5, Build: 14.0.3023.8, KB: KB4092643, Release Date: March 2018, Download: https://support.microsoft.com/en-us/help/4092643/cumulative-update-5-for-sql-server-2017; Update Version: MSSQL 2017 RTM CU-4, Build: 14.0.3022.28, KB: KB4056498, Release Date: February 2018, Download: https://support.microsoft.com/en-us/help/4056498/cumulative-update-4-for-sql-server-2017; Update Version: MSSQL 2017 RTM CU-3, Build: 14.0.3015.40, KB: KB4052987, Release Date: January 2018, Download:...
read more

Microsoft SQL Server 2016 / RTM (13.0.1601.5) / SP1 (13.0.4001.0 or 13.1.4001.0)

Microsoft SQL Server 2016 / RTM (13.0.1601.5) / SP1 (13.0.4001.0 or 13.1.4001.0)
SQL SERVER 2016 SP1 Update Version: MSSQL 2016 SP1 CU-8, Build: 13.0.4474.0 / 13.1.4474.0, KB: KB4077064, Release Date: March 2018, Download: https://support.microsoft.com/en-us/help/4077064/cumulative-update-8-for-sql-server-2016-sp1; Update Version: MSSQL 2016 SP1 CU-7, Build: 13.0.4466.4 / 13.1.4466.4, KB: KB4057119, Release Date: January 2018, Download: https://support.microsoft.com/en-us/help/4057119/cumulative-update-7-for-sql-server-2016-sp1; Update Version: MSSQL 2016 SP1 CU-6, Build: 13.0.4457.0 / 13.1.4457.0, KB: KB4037354, Release...
read more

« Previous Entries