Category Archives: Windows

Stuff about Microsoft’s answer to elevator music

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 […]

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 […]

A few group policies I use on Windows 10

Disable the lock screen, always showing a login prompt: Group Policy Editor (gpedit.msc) => Computer Configuration => Administrative Templates => Control Panel => Personalization => Do not display the lock screen Disallow the use of OneDrive: Group Policy Editor (gpedit.msc) => Computer Configuration => Administrative Templates => Windows Components => OneDrive => Prevent the usage […]