Skip to content

Instantly share code, notes, and snippets.

View DamianSuess's full-sized avatar
👍
Enjoying every day

Damian DamianSuess

👍
Enjoying every day
View GitHub Profile
@DamianSuess
DamianSuess / GitTools.ps1
Created January 14, 2019 17:44
PowerShell Git Helpers
<#
Git Helpers for PowerShell
Author: Damian Suess
Revision: 2.b - 2018-07-30 (2018-10-03)
TODO:
- GitCheckIn $message (check-in/push)
- GitPush - Set branch tracking or no tracking
Change Log:
@DamianSuess
DamianSuess / Gist-Table-Of-Contents.md
Last active June 24, 2022 16:43
Gist Table of Contents
@DamianSuess
DamianSuess / TSQL-SearchJobsForText.md
Created January 3, 2019 16:13
TSQL Search Jobs for text

The following is an example of how to search SQL Jobs for text using TSQL

SQL 2005-2017

-- SQL 2005-2008 - Search all Jobs
SELECT j.job_id, s.srvname, j.name, js.step_id, js.command, j.enabled
FROM msdb.dbo.sysjobs j
JOIN msdb.dbo.sysjobsteps js ON js.job_id = j.job_id 
JOIN master.dbo.sysservers s ON s.srvid = j.originating_server_id
WHERE js.command LIKE N'%...%'
@DamianSuess
DamianSuess / TSQL-SearchForeignKeys.md
Last active January 3, 2019 16:11
TSQL Search foreign keys

The following is an example on how to search Foreign Keys using TSQL

Tested using MS SQL Server 2000-2017

List Foreign Key Constraints

-- List Foreign Key Constraints on table. Ex: D_TRANS_ACCOUNT_ENTRY
DECLARE @tableName sysname
SET @tableName = '...' -- Your table name goes here
SELECT
@DamianSuess
DamianSuess / TSQL-SearchTables.md
Last active January 3, 2019 16:05
TSQL Search tables for string

The following is an example of how to search tables for a value. It may not be the most efficient but it works

Tested against MS SQL Server 2000-2017

Example

DECLARE @SearchStr nvarchar(100);
SET @SearchStr = 'SEARCH TEXT HERE';

CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630));
@DamianSuess
DamianSuess / TSQL-SearchTriggers.md
Last active January 3, 2019 15:56
TSQL Search triggers

The following example shows you how to search the database's triggers for a string using MS SQL Server 2000-2017

Example

-- Search all Triggers (rev 1)
-- Usage: Replace '%...%' with you search string
SELECT
  Tables.Name TableName,
  Triggers.name TriggerName,
 Triggers.crdate TriggerCreatedDate,
@DamianSuess
DamianSuess / TSQL-SearchForTableColumnName.md
Created January 3, 2019 15:46
TSQL Search tables for column name

Use this script to search through all Stored Procedures to find a particular piece of data. Such as: Table usage, Column Names, etc.

Method 1

-- [ Find tables using Column and generate SELECT statement ] --
select 'select ''' + o.name + ''' ,* from ' + o.name + ' where ' + c.name + ' = ''...''', * from sysobjects o, syscolumns c
where o.id = c.id and o.xtype = 'u'
and c.name like '%Device_Id%'   -- COLUMN NAME HERE
order by o.Name;
@DamianSuess
DamianSuess / TSQL-SearchStoredProcs.md
Last active January 3, 2019 15:14
TSQL Search Stored Procedures

The following provides a couple of options on how to search MS SQL stored procedures for text. This can be useful if you're trying to find references to pieces of code or notes.

The following has been tested against MS SQL Server 2000-2016

Method 1

-- Search Stored Procedures Script
-- Input: Replace '%...%'  with you search string.  i.e. '%D_Request%'
SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
@DamianSuess
DamianSuess / SpecialFolderLocations.md
Last active January 22, 2025 21:58
C# Environment.SpecialFolder
@DamianSuess
DamianSuess / PS-CleanDuplicateModules.ps1
Last active October 22, 2018 17:32
PS - Cleanup duplicate installed modules
write-host "Removing all older duplicate versions of installed modules";
write-host " 1. be sure to run this as an admin" -foregroundcolor yellow;
write-host " 2. (You can update all your Azure RM modules with update-module Azurerm -force)";
$mods = Get-InstalledModule;
foreach ($Mod in $mods)
{
write-host "Checking '$($mod.name)'";
$latest = Get-InstalledModule $mod.name;