Skip to content

Instantly share code, notes, and snippets.

Avatar
⛑️
solving problems

steve withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / sql-server-row-count-for-db-tables.sql
Last active Aug 6, 2021
SQL Server Row Count for all Database Tables
View sql-server-row-count-for-db-tables.sql
-- SQL Server Row Count for all Database Tables
USE [SomeTable]
GO
DECLARE @QueryString NVARCHAR(MAX);
SELECT @QueryString =
COALESCE(@QueryString + ' UNION ALL ','')
+ 'SELECT '
@stevewithington
stevewithington / sql-kill-all-transactions.sql
Created Aug 6, 2021
Kill all transactions in a database during a restore to avoid issues with exclusive access.
View sql-kill-all-transactions.sql
-- 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 Apr 16, 2021
Bash ANSI Variables for Colorized Echo Output
View bash-ansi-variables-colorized-echo-output.md

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 Apr 7, 2021
SQL: Get total and average row count per table and/or database
View get-total-average-row-counts.sql
/* 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 Mar 30, 2021 — forked from LukePammant/auto-increment-npm
Auto-increment NPM package in Azure Pipelines and publish to Azure Artifacts
View auto-increment-npm
trigger:
branches:
include:
- develop
- master
paths:
include:
- ./
resources:
@stevewithington
stevewithington / powershell-create-system-dsn-via-csv-import.md
Last active Apr 14, 2021
Powershell: Create/Add Windows System DSN via .CSV Import
View powershell-create-system-dsn-via-csv-import.md

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
View add-images-to-gist.md

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 Feb 25, 2021
Windows Outlook Conditional CSS: Targeting Specific MSO Versions
View mso-versions.md

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]-->
View get-latest-git-tag.sh
# 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 Jan 12, 2021
SQL: Update a table with Common Table Expression (CTE)
View sql-cte-update.sql
/*
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