Posts Tagged ‘SQL Server’

Get a list of all your database files

I needed a list of all the database files on a SQL Server instance. Here’s how to get this easily. First create a temp table to hold the data like so.. ?View Code TSQLSELECT * INTO #db_files FROM sys.database_files; Truncate it so we don’t duplicate nay data. ?View Code TSQLTRUNCATE TABLE #db_files; Next we use […]

Functions & sargable queries

Using functions improperly in your where clauses always prevents index usage right? I’ve been reviewing some queries generated by linq and I’ve found out this isn’t always the case. A quick demo… Create a temp tables and insert some data ?View Code TSQLCREATE TABLE #test ( id INTEGER NOT NULL PRIMARY KEY CLUSTERED, [name] VARCHAR(100) NOT NULL ); […]

Are you checking for possible integer overflow?

I realized I wasn’t! We run a couple of systems that I know stick a mass of records through on a daily basis. Better start doing this then or I might end up doing a whoopsie! Here’s a script I’ve quickly knocked up to make checking this simple. This script will check the specified tables TINYINT, SMALLINT, INT & BIGINT values […]

Failed to configure Node and Disk Majority quorum with ‘[Disk Group Name]’.

I was changing the drive used as a disk quorum today and received the following error at the end of the wizard in Failover Cluster Manager; Failed to configure Node and Disk Majority quorum with ‘[Disk Group Name]’. I then noticed the drive I was trying to add was in the “SQL Server (MSSQLSERVER)” group […]

Check Mirroring Status with Powershell

Here’s a simple Powershell snippet to check the mirroring status on your SQL Server instances. ?View Code POWERSHELL# Load SMO extension [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;   # Servers to check $sqlservers = @("server1", "server2", "server3"); foreach($server in $sqlservers) { $srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server; # Get mirrored databases $databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true}; Write-Host […]