Skip to content

Instantly share code, notes, and snippets.

View stevewithington's full-sized avatar
⛑️
solving problems

Steve Withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / sql-kill-all-transactions.sql
Created August 6, 2021 12:55
Kill all transactions in a database during a restore to avoid issues with exclusive access.
-- Kill all transactions in a database during a restore to avoid issues with exclusive access.
DECLARE @SQL VARCHAR(8000)
SELECT @SQL=COALESCE(@SQL,'')+'Kill '+CAST(spid AS VARCHAR(10))+ '; '
FROM sys.sysprocesses
WHERE DBID=DB_ID('AdventureWorks')
PRINT @SQL --EXEC(@SQL) Replace the print statement with exec to execute
@stevewithington
stevewithington / bash-ansi-variables-colorized-echo-output.md
Created April 16, 2021 14:26
Bash ANSI Variables for Colorized Echo Output

Bash ANSI Variables for Colorized Echo Output

I wanted to be able to make some messaging stand out while running Azure Pipeline Builds. This is ultimately what worked for me.

Example Usage

Some simple examples of how to use the variables listed below.

One Color for the Entire Line

@stevewithington
stevewithington / get-total-average-row-counts.sql
Created April 7, 2021 16:03
SQL: Get total and average row count per table and/or database
/* SQL: Get total and average row count per table and/or database */
USE SomeDB;
GO
CREATE TABLE #counts
(
table_name varchar(255),
row_count int
)
@stevewithington
stevewithington / auto-increment-npm
Created March 30, 2021 22:43 — forked from LukePammant/auto-increment-npm
Auto-increment NPM package in Azure Pipelines and publish to Azure Artifacts
trigger:
branches:
include:
- develop
- master
paths:
include:
- ./
resources:
@stevewithington
stevewithington / powershell-create-system-dsn-via-csv-import.md
Last active January 13, 2023 06:12
Powershell: Create/Add Windows System DSN via .CSV Import

Powershell: Create/Add Windows System DSN via .CSV Import

You can create/add/update/get a Windows System DSN pretty easily with Powershell.

Example dsn.csv file

Database, SystemDSN, Server
AAA, AAA_DSN, SomeIP\User
@stevewithington
stevewithington / add-images-to-gist.md
Last active February 26, 2021 13:13
Add Image(s) to Gist

Add Image(s) to Gist

If you don't already have an existing gist, you'll need to create one before proceeding.

Clone Your Gist

git clone https://gist.github.com/<hash>.git # via https
git clone git@gist.github.com:<hash>.git     # via ssh
@stevewithington
stevewithington / mso-versions.md
Last active February 25, 2021 17:34
Windows Outlook Conditional CSS: Targeting Specific MSO Versions

Targeting Specific Outlook Versions

Outlook version(s) Code
All Windows Outlook (Most common) <!--[if mso]> your code <![endif]-->
Outlook 2000 <!--[if mso 9]> your code <![endif]-->
Outlook 2002 <!--[if mso 10]> your code <![endif]-->
Outlook 2003 <!--[if mso 11]> your code <![endif]-->
Outlook 2007 <!--[if mso 12]> your code <![endif]-->
Outlook 2010 <!--[if mso 14]> your code <![endif]-->
@stevewithington
stevewithington / get-latest-git-tag.sh
Created February 23, 2021 22:25
Git: Get Latest Tag
# get latest tag for the current branch
git describe --tags
# outputs > v*.*.*-{hash}
# get latest tag for the current branch without the hash
git describe --tags --abbrev=0
# outputs > v*.*.*
# get latest tag across all branches
git describe --tags $(git rev-list --tags --max-count=1)
@stevewithington
stevewithington / sql-cte-update.sql
Last active January 12, 2021 19:37
SQL: Update a table with Common Table Expression (CTE)
/*
Example of how to update a table in SQL using a Common Table Expression (CTE)
*/
USE [SomeTable]
GO
;WITH cte AS (
SELECT te.LandEntityId, te.BirthDate, te.BirthDateId, dd.DateId
FROM TypedEntity te
@stevewithington
stevewithington / dim-date.sql
Last active January 13, 2021 22:51
SQL: Date Dimension Table
USE [SomeDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON