Converted into a module: https://github.com/tcartwright/tcdbtools
PS Gallery link: https://www.powershellgallery.com/packages/tcdbtools/
| # https://4bes.nl/2021/09/19/update-all-powershell-modules-on-a-system/ | |
| <# | |
| TIM C: Changes: | |
| - Added scope parameter so scope could be controlled | |
| - altered code to always check for old versions, as this script may not have done the install, but it can still remove old versions | |
| - changed contains and othercomparison syntax to be case insensitive | |
| - altered logic around when the module is not found in the gallery to make the verbose output clearer | |
| - added version parses around the version compares so string comparisons do not screw up the comparison | |
| - added admin check when using AllUsers |
Converted into a module: https://github.com/tcartwright/tcdbtools
PS Gallery link: https://www.powershellgallery.com/packages/tcdbtools/
Converted into a module: https://github.com/tcartwright/tcdbtools
PS Gallery link: https://www.powershellgallery.com/packages/tcdbtools/
| IF OBJECT_ID('dbo.ErrorHandler') IS NULL BEGIN | |
| EXEC ('CREATE PROCEDURE dbo.ErrorHandler AS BEGIN SELECT 1; END;'); | |
| END | |
| GO | |
| --our error handling procedure | |
| ALTER PROCEDURE dbo.ErrorHandler @procName NVARCHAR(128), @ErrorMessage NVARCHAR(4000) OUTPUT, @ErrorSeverity INT OUTPUT, @ErrorState INT OUTPUT | |
| AS | |
| BEGIN | |
| /* declare sessions keys that are safe for multiple sessions on a single connection */ |
| /* | |
| Authors: Matthew Naul, Tim Cartwright | |
| Purpose: to build a stack trace so that nested stored proces can be followed in the case of an exception. | |
| */ | |
| USE tempdb -- change this to the db of your choice. or put it master and make it a system stored proc | |
| GO | |
| IF OBJECT_ID('dbo.ErrorHandler') IS NULL BEGIN | |
| EXEC ('CREATE PROCEDURE dbo.ErrorHandler AS BEGIN SELECT 1; END;'); |
| /* | |
| Author: Tim Cartwright | |
| 1) Leave the @dbname variable empty or null for all databases | |
| 2) Changed the @dbname variable to a specific variable to only get the queries for that database. | |
| RETURNS: The queries with the highest cost, and longest working time with the worst offenders being at the top of the list. | |
| */ | |
| DECLARE @dbname sysname = '', -- '', |