MS SQL – Normalise Case

Wow not wrote any notes for a very long time…! Recently I’ve had an issue where some text was presented in a table, and I needed to normalise the text. For example: Would need to become: With thanks to Justin Cooney this was possible using the SQL below: The code…

Migrating Servers to Azure – Activating Windows

Recently I have migrated several servers from Vultr to Microsoft Azure. As part of this migration, windows became un-activated – most likely because Vultr runs it’s own KMS service and it is no longer able to contact the server: In order to resolve this, I changed the product key to…

SQL Server – Identify Unused Indexes

Within SQL Server an index is used to optimise the reading of data from the database. However the side effect of having such an index is reduced write speed for inserts and updates. This is because SQL Server will need to update and maintain the index. Running the below SQL…

Windows 10 – Missing Taskbar Icons

Had a very odd issue with Windows 10 and taskbar menu items missing: After lots of research, I’ve partially fixed this by running the following from an elevated command prompt: for /R "%APPDATA%\Microsoft\Windows\Start Menu\Programs\" %f in (.lnk) do copy /b "%f"+,, "%f" 1>nul for /R "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\" %f in (.lnk)…

Using Dynamic Management Views to Recommend Indexes in SQL Server

Did you know that SQL Server provides several views which provide information on recommended indexes? Using the following SQL, you can identify where SQL recommends indexes, ordered by potential performance boost from adding the suggested index. Obviously you may wish to review these manually, rather than just blindly creating, but…

Azure SQL Database View Running Transactions / Blocking

With the Azure SQL Database, sometimes you want to view the current running transactions. Unfortunately there is no GUI as such like there is with normal SQL Server (right click, “Activity Monitor”), however it can be grabbed by executing sys.dm_exec_requests. The following SQL is very useful as it shows details…

Azure SQL Database Index Size

Recently I’ve been doing some work on optimising indexes within Azure SQL Database. The following SQL from Daniel is very useful in showing the status of all the current indexes within a SQL Database. The SQL works for both SQL Server 2014 onwards, plus Azure SQL Database. I have not…

Run Programs as a Domain User from None Domain Account

Following on from my blog post for running Microsoft Dynamics Nav as a different user here, I have done some further investigation of the runas command. Typically the RunAs command is used for local authentication, however there is a little known switch which bypasses local authentication and uses it for…

Delete Duplicate Records – Leave Only 1 Behind MS SQL

Recently I’ve had to delete duplicate records from the Record Link table in Microsoft Dynamics Nav. Using the following SQL, (which uses the OVER clause for partitioning) this deletes all duplicate records, leaving the first unique item behind. The SQL can be updated easily to function for other tables /…