Some notes on software development... RSS 2.0
# Tuesday, December 23, 2014

I recently, accidently, put one of my large SQL Server databases ‘In Recovery’ and had no idea how long it was going to take to recover. Thankfully Tim Laqua has created a couple of scripts that query the error log, one for 2008 and one for 2012, that tells you roughly how long the recovery process will take. Below is a copy of the SQL Server 2012 version:

DECLARE @DBName VARCHAR(64) = '<DatabaseName>' DECLARE @ErrorLog AS TABLE([LogDate] CHAR(24), [ProcessInfo] VARCHAR(64), [TEXT] VARCHAR(MAX)) INSERT INTO @ErrorLog EXEC master..sp_readerrorlog 0, 1, 'Recovery of database', @DBName SELECT TOP 5 [LogDate] ,SUBSTRING([TEXT], CHARINDEX(') is ', [TEXT]) + 4,CHARINDEX(' complete (', [TEXT]) - CHARINDEX(') is ', [TEXT]) - 4) AS PercentComplete ,CAST(SUBSTRING([TEXT], CHARINDEX('approximately', [TEXT]) + 13,CHARINDEX(' seconds remain', [TEXT]) - CHARINDEX('approximately', [TEXT]) - 13) AS FLOAT)/60.0 AS MinutesRemaining ,CAST(SUBSTRING([TEXT], CHARINDEX('approximately', [TEXT]) + 13,CHARINDEX(' seconds remain', [TEXT]) - CHARINDEX('approximately', [TEXT]) - 13) AS FLOAT)/60.0/60.0 AS HoursRemaining ,[TEXT] FROM @ErrorLog ORDER BY [LogDate] DESC


Tuesday, December 23, 2014 3:40:51 PM (GMT Standard Time, UTC+00:00)  #    -
SQL Server
# Wednesday, November 26, 2014

Quick code snippet for SQL Server batch deletion:

-- Delete in batches of 5000 DECLARE @rowcount INT = 1, @batchsize INT = 5000 WHILE (@rowcount != 0) BEGIN DELETE TOP (@batchsize) SomeBigTable SELECT @rowcount = @@ROWCOUNT END

There is an excellent article over at using different chunking techniques with performance metrics:

Wednesday, November 26, 2014 10:56:31 AM (GMT Standard Time, UTC+00:00)  #    -
SQL Server

Before using JavaScript’s RegExp object you may need to escape regular expression characters. These characters are: ( ) [ { * + . $ ^ \ | ?

I’m no RegEx expert but the code I found that works for me is:

text.replace(/([()[{*+.$^\\|?])/g, '\\$1');


Thanks once again StackOverflow :-)


Wednesday, November 26, 2014 10:47:48 AM (GMT Standard Time, UTC+00:00)  #    -
JavaScript | Regular Expressions
# Wednesday, June 04, 2014

Multiple desktop sessions for the same user is disabled by default on Windows Server 2008R2. To enable multiple sessions for the same user:

  1. Go to Administrative Tools->Remote Desktop Services->Remote Desktop Session Host Configuration
  2. Select properties on the ‘Restrict each user to a single session’ general setting.
  3. Un-check the ‘Restrict each user to a single session’ checkbox.


After saving all further new remote desktop sessions will be new unless ‘console mode’ RDP is used.



Wednesday, June 04, 2014 2:32:14 PM (GMT Standard Time, UTC+00:00)  #    -
Remote Desktop | Windows

Sign In
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2016
Hadrian Phillips

All Content © 2016, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)