Category Archives: Windows

Stuff about Microsoft’s answer to elevator music

Setting all SQL Server databases to “simple” recovery model and deleting all the transaction logs

Sometimes, you just want things brutally simple and stupid. I was searching for how to do this, and stumbled upon this post on SQL Server Central. Turns out the query listed there doesn’t handle databases with weird names, containing version numbers with “.” in them, for instance. Thus, I modified it slightly, adding brackets and […]

Debugging SQL Server Query Performance

To enable timing of your query: SET STATISTICS TIME ON Time statistics provides output like this in the “Messages” tab of SSMS after running a query: (127 row(s) affected)  SQL Server Execution Times:    CPU time = 0 ms,  elapsed time = 42 ms. To show IO statistics: SET STATISTICS IO ON ..which provides stuff […]

Force SQL Server Database offline

If you right click a database in SSMS and select Tasks => Take Offline, you might find yourself staring at this dialog for hours, if there are active sessions running queries on your database. Here’s how to force it to go offline, rolling back any current transactions. Replace [dbname] with the name of your database. […]

Fixing empty search results in the Windows 10 Settings (the shiny new Control Panel)

This happened on a few machines I am responsible for, after the upgrade to Windows 10. You click “Start”, type “updates”, it suggests “Check for Updates” in the “Settings” app, you click <enter> and it opens an empty settings window with no search results. Great. After looking around for a while, I stumbled over the […]

Export certificates marked as not exportable in the Windows certificate manager

So, you need the private key for a certificate on Windows, for some innocent snooping around with Wireshark, but someone marked it as not exportable. Now what? Cue Gentil Kiwi and his tool Mimikatz. The following commands will extract the certificates from the local store: crypto::capi crypto::certificates /systemstore=CERT_SYSTEM_STORE_LOCAL_MACHINE /export The password for the pfx files […]

Enabling Quick Launch in Windows 10

I have my taskbar set to “Use small taskbar buttons” and “Never combine”, probably as much out of habit as anything else. This means that when I pin programs to the taskbar, opening one of them, suddenly making it display a title for one or more windows, will push any pinned programs to its right […]

Find and kill long running MS SQL Server queries

I have to admit this is cargo cult SQL to me, but here’s how to find running queries, sorted by their total elapsed time: SELECT [sqltext].[TEXT], [req].[session_id], [req].[status], [req].[command], [req].[cpu_time], [req].[total_elapsed_time] FROM [sys].[dm_exec_requests] [req] CROSS APPLY [sys].[dm_exec_sql_text](sql_handle) AS sqltext ORDER BY [req].[total_elapsed_time] DESC To kill a given query, use: kill <session_id> ..without the brackets <>, […]

Error 0x80041002 from PowerShell after upgrade to Windows 10

On a box I just upgraded, we run a script that’s supposed to add a new scheduled task. After the upgrade, attempting to create a new trigger would return this beauty: PS C:\Users\User> New-ScheduledTaskTrigger -AtStartup New-ScheduledTaskTrigger : Method “NewTriggerByStartup” not found + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/…S_ScheduledTask) [New-ScheduledTaskTrigger], CimException + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger The solution […]