Oct 19

Multiline everything matches in VBScript and Javascript

Apparently VBScript uses the same syntax as javascript for regular expressions, so they both suffer from the “. means everything .. except that it doesn’t” bug. You’d think that [.s] would do the trick, but it doesn’t. The best workaround I’ve seen is [sS] (that is, whitespace and not-whitespace).

Oct 18

Maintenance Plan Cleanup Tasks

My observations suggest that you can only add a maintenance cleanup task (to delete expired backups) from the machine on which SQL Server resides. When I run the maintenance plan wizard from SSMS on my own machine, I don’t get that option.

Once you successfully add a maintenance cleanup task, how do you get it to delete .bak, .dif and .trn files all in the same task? Leaving the extension box blank doesn’t result in anything getting deleted. The secret is to enter * as the extension. The period before the extension should be omitted.

Oct 17

Most Costly Queries Running Right Now

Out of memory? Use the sys.dm_exec_query_memory_grants DMV to find the heaviest query running right now and kill it.

By memory usage:

SELECT session_id, (requested_memory_kb/1024.AS [Requested Memory (MB)], grant_time, query_costtext
FROM sys.dm_exec_query_memory_grants
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t
ORDER BY requested_memory_kb DESC

By query cost:

SELECT session_id, (requested_memory_kb/1024.AS [Requested Memory (MB)], grant_time, query_costtext
FROM sys.dm_exec_query_memory_grants
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t
ORDER BY query_cost DESC

Oct 17

Querying Outlook

One of my developers is proposing to put the text of every error email that the web application generates into the database because they contain debug information. I’m not certain that anyone will use this information, so I wanted to estimate how space this was going to take up. I had a bunch of the error emails in my mailbox, and I discovered that if you highlight a bunch of messages, copy, and paste into Excel, you get the same grid. The sizes are strings (“34 KB”), but you can then use a formula to isolate the number (“=INT(LEFT(D2, LEN(D2)-3))”) and use the AVERAGE function on them.

Oct 15

HTTP Server Status Codes

RFC 2616

Informational 1xx

  • 100 Continue
  • 101 Switching Protocols

Successful 2xx

  • 200 OK
  • 201 Created
  • 202 Accepted
  • 203 Non-Authoritative Information
  • 204 No Content
  • 205 Reset Content
  • 206 Partial Content

Redirection 3xx

  • 300 Multiple Choices
  • 301 Moved Permanently
  • 302 Found
  • 303 See Other
  • 304 Not Modified
  • 305 Use Proxy
  • 306 (Unused)
  • 307 Temporary Redirect

Client Error 4xx

  • 400 Bad Request
  • 401 Unauthorized
  • 402 Payment Required
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed
  • 406 Not Acceptable
  • 407 Proxy Authentication Required
  • 408 Request Timeout
  • 409 Conflict
  • 410 Gone
  • 411 Length Required
  • 412 Precondition Failed
  • 413 Request Entity Too Large
  • 414 Request-URI Too Long
  • 415 Unsupported Media Type
  • 416 Requested Range Not Satisfiable
  • 417 Expectation Failed

Server Error 5xx

  • 500 Internal Server Error
  • 501 Not Implemented
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout
  • 505 HTTP Version Not Supported