SQL Server full and transaction log backups completing but differential backups failing because of Veeam B&R configuration

Scenario

I recently refreshed our SQL Server Maintenance Plans, but System Centre Essentials has been intermittently reporting failures of the daily differential backups, with an error like this:

Executing the query “BACKUP DATABASE [DBNAME] TO DISK = N’…” failed with the following error: “Cannot perform a differential backup for database “DBNAME”, because a current database backup does not exist. Perform a full database backup by reissuing BACKUP DATABASE, omitting the WITH DIFFERENTIAL option. BACKUP DATABASE is terminating abnormally.”. Possible failure reasons: Problems with the query, “ResultSet” property not set correctly, parameters not set correctly, or connection not established correctly.

The strange thing is that the logs show all Weekly Full backups have completed without error. If I run a manual Full Backup, the next Differential Backup will complete, then the following day will fail.

Solution

First, I used the following query to show more details on the backups (make sure you select the DB in SSMS first):

[Read more…]

Virtualizing SQL Server on Windows Server 2012 – New Features and Performance Tuning

I recently read this excellent post on the TechNet Blogs: http://blogs.technet.com/b/keithmayer/archive/2012/08/30/virtualizing-microsoft-sql-server-on-windows-server-2012-winserv-mssql-itpro-sqlpass.aspx

The post highlights many new features in the latest version of Hyper-V, then goes over sizing virtualized SQL Server workloads and performance tuning.

Find out what’s going on with your SQL Servers

Have your SQL Servers ever gone mental on you all of a sudden, and you wish you could quickly see an overview of what was running at the time?

I just found these useful queries on a Spiceworks forum.

The first one will show you what is currently being executed on your server:

SELECT s.session_id AS SessionID,
 s.login_time AS LoginTime,
 s.[host_name] AS HostName,
 s.[program_name] AS ProgramName,
 s.login_name AS LoginName,
 s.[status] AS SessionStatus,
 st. AS SQLText,
 (s.cpu_time / 1000) AS CPUTimeInSec,
 (s.memory_usage * 8) AS MemoryUsageKB,
 (CAST(s.total_scheduled_time AS FLOAT) / 1000) AS TotalScheduledTimeInSec,
 (CAST(s.total_elapsed_time AS FLOAT) / 1000) AS ElapsedTimeInSec,
 s.reads AS ReadsThisSession,
 s.writes AS WritesThisSession,
 s.logical_reads AS LogicalReads,
 CASE s.transaction_isolation_level
 WHEN 0 THEN 'Unspecified'
 WHEN 1 THEN 'ReadUncommitted'
 WHEN 2 THEN 'ReadCommitted'
 WHEN 3 THEN 'Repeatable'
 WHEN 4 THEN 'Serializable'
 WHEN 5 THEN 'Snapshot'
 END AS TransactionIsolationLevel,
 s.row_count AS RowsReturnedSoFar,
 c.net_transport AS ConnectionProtocol,
 c.num_reads AS PacketReadsThisConnection,
 c.num_writes AS PacketWritesThisConnection,
 c.client_net_address AS RemoteHostIP,
 c.local_net_address AS LocalConnectionIP
 FROM sys.dm_exec_sessions s INNER JOIN sys.dm_exec_connections c
 ON s.session_id = c.session_id
 CROSS APPLY sys.dm_exec_sql_text(c.most_recent_sql_handle) AS st
 WHERE s.is_user_process = 1
 ORDER BY ElapsedTimeInSec DESC

This next one can show blocking processes… you can use the blocking session ID to track down the other processes:

SELECT dm_ws.wait_duration_ms,
 dm_ws.wait_type,
 dm_es.status,
 dm_t.TEXT,
 dm_ws.session_ID,
 dm_es.cpu_time,
 dm_es.memory_usage,
 dm_es.logical_reads,
 dm_es.total_elapsed_time,
 dm_es.program_name,
 DB_NAME(dm_r.database_id) DatabaseName,
 dm_ws.blocking_session_id,
 dm_r.wait_resource,
 dm_es.login_name,
 dm_r.command,
 dm_r.last_wait_type
 FROM sys.dm_os_waiting_tasks dm_ws
 INNER JOIN sys.dm_exec_requests dm_r ON dm_ws.session_id = dm_r.session_id
 INNER JOIN sys.dm_exec_sessions dm_es ON dm_es.session_id = dm_r.session_id
 CROSS APPLY sys.dm_exec_sql_text (dm_r.sql_handle) dm_t
 WHERE dm_es.is_user_process = 1

Reference

Adding a node to a SQL Server 2008 R2 Failover Cluster using Server 2008 R2

Scenario

You’ve successfully installed and configured a SAN, a Failover Cluster and an instance of SQL Server 2008 R2 on one node. Now you need add another node to this cluster so the SQL Server instance can failover.

Solution

  1. From the setup menu, select Installation > Add node to a SQL Server failover cluster:

  2. Click OK after the first set of checks:
    [Read more…]

Installing SQL Server 2008 R2 on a Failover Cluster using Server 2008 R2

Scenario

You’ve configured a Failover Cluster using Server 2008 R2, and now you want to install SQL Server 2008 R2.

Solution

Changes

A few changes were made to the simple Failover Cluster that was previously configured:

  • Several LUNs were added to the FreeNAS VM so separate disks could be used for each function:
  • 3 x Network Interface Cards (NICs) were configured on each node, each on a different subnet:
    • LAN: 10.10.10.0/24
    • SAN: 10.10.20.0/24
    • Heartbeat: 10.10.30.0/24
  • The FreeNAS interface was configured on the SAN subnet (10.10.20.220).

This time round, the Failover Cluster Validation Report didn’t have a single warning; all green ticks 😉

[Read more…]

The Microsoft SQL Server Express Edition installer returned error code 2064843076

Scenario

You’ve just tried to install VMware vCenter with the option to use SQL Server Express, but the installation fails with the following error:

The Microsoft SQL Server Express Edition installer returned error code ‘2064843076’

Solution

  1. Click Explore Media to open an Explorer window:
  2.  Right-click autorun.exe and select Run as administrator:
  3. Every process that is started from the autorun screen will now have full admin rights, so SQL Server will install fine.

Display owner of Maintenance Plans using SQL Server 2008 R2

Whilst troubleshooting an issue with backups, I wanted to check the owner of all Maintenance Plans.

I found the following query that does just that:

SELECT sj.name AS JobName,
CASE WHEN sj.[Enabled] = 1
THEN 'Yes'
ELSE 'No'
END AS JobIsEnabled,
sl.name AS OwnerName
FROM msdb.dbo.sysjobs AS sj INNER JOIN master.dbo.syslogins AS sl
ON sj.owner_sid = sl.sid
ORDER BY JobName

SQL Server Maintenance Plans

Maintenance Scripts are better

I’ve just been reviewing our Maintenance Plans (MPs). After readings a few best practice articles, it seems I’d be better off using scripts instead of MPs.

When using the Reorganise and Rebuild tasks within a MP, they will run regardless of the index fragmentation. Using scripts I could check to see if indexes actually need a little TLC, based on the level of fragmentation, eg.

  • < 5% = no reorganise/rebuild
  • 5-30% = reorganise
  • > 30% = rebuild

Understanding SQL Server Backups and Recovery

I’ve read many help files/articles/posts on backup and recovery over the years, but I’ve recently read some of the best yet that have filled in some gaps when it comes to SQL Server:

SQL Server Service Pack version query

I was just checking the Service Pack versions on our SQL servers. Here’s the query I used:

SELECT
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('ProductLevel') AS ProductLevel,
SERVERPROPERTY('ProductVersion') AS ProductVersion

The Community Technology Preview (CTP) of SP2 for SQL Server 2008 is already out, so it shouldn’t be too long for general release, so in the meantime we’re up-to-date using SP1 🙂

SQL Server 2005 is at its latest Service Pack on version 4:

Standard Edition (64-bit) – SP4 – 9.00.5057.00