Skip to content

Instantly share code, notes, and snippets.

View sqldeployhelmet's full-sized avatar

josh sqldeployhelmet

View GitHub Profile
@sqldeployhelmet
sqldeployhelmet / Mastodon_Config.toml
Created December 18, 2022 19:30
Mastodon Social params for Hugo
[params.social.Mastodon]
# your social ID
id = "@xxxx"
# prefix of your social link
prefix = "https://<your mastodon instance here>/"
# content hovering on the icon
title = "Mastodon"
@sqldeployhelmet
sqldeployhelmet / updateIntegers.ps1
Last active October 10, 2022 19:49
Updating SQL Data Types with DBATools
<#
Author: josh smith
Date: 2022-09-22
Purpose: The challenge of converting integers to bigintegers was mainly one of time and simply
altering the column data type led to _extremely_ long runtimes that could be mitigated
by creating copy of the table from scratch with the correct data type and then transfering
the data in. This script leverages the dbatools PowerShell module (www.dbatools.io) to do just that.
@sqldeployhelmet
sqldeployhelmet / ExtractSQLDocs.ps1
Created December 11, 2020 20:03
PowerShell script for extracting a Jekyll ready files from SQL Doc markdown files.
<#
Author: Josh Smith
Created: 2020-09-03
This script will parse through SQL Doc Generated markdown files to create Jekyll friendly
db documentation.
Should be run from the root directory of the documentation repository.
#>
function createHeader { param ($subject, $link, $page)
@sqldeployhelmet
sqldeployhelmet / SQLUserPermissionsQry.sql
Last active November 28, 2020 19:35
Quick SQL Instance and DB Access Collection
/* We collect the results daily and haven't been too concerned
about lost history if a particular instance fails occasionally */
DELETE FROM
dbo.secPoll;
CREATE TABLE ##userQuery
(
serverName VARCHAR(255)
, databaseName VARCHAR(255)
@sqldeployhelmet
sqldeployhelmet / backuplist.json
Last active March 4, 2020 20:47
Output from the CosmosDB backup list script.
[
{
"ContainerName" : "myFirstContainer",
"DatabaseName" : "myFirstDatabase",
"ResourceName" : "cosmos-db-service-1"
},
{
"ContainerName" : "mySecondContainer",
"DatabaseName" : "myFirstDatabase",
"ResourceName" : "cosmos-db-service-1"
@sqldeployhelmet
sqldeployhelmet / ListCosmosDBContainers.ps1
Last active March 4, 2020 20:27
Powershell script to query cosmosdb services for a list of databases and containers in them.
<#
Author: Josh Smith
Created: 2020-03-02
Purpose: Will pull all databases and containers from known CosmosDB resources.
Cosmos db services must be known and added to the array below (paired with the
associated resource group).
#>
<# add cosmos db resource and groups here as needed: #>
@sqldeployhelmet
sqldeployhelmet / TeamCityBuildNumber.ps1
Created January 30, 2020 21:43
PS Code for Dynamically setting a build number.
# The build number format is YYYY.MM.B (Year.Month.BuildCounter)
$MonthCounter = ([DateTime]::Now.Month).ToString().PadLeft(2, "0")
$YearCounter = ([DateTime]::Now.Date.Year).ToString()
$DayCounter = ([DateTime]::Now.Day).ToString().PadLeft(2, "0")
$TimeCounter = ([DateTime]::Now.Hour).ToString().PadLeft(2, "0")
$MinuteCounter = ([DateTIme]::Now.Minute).ToString().PadLeft(2, "0")
$counter = "$YearCounter.$MonthCounter.$DayCounter.$TimeCounter" + $MinuteCounter
@sqldeployhelmet
sqldeployhelmet / cosmosDB.json
Last active October 2, 2019 04:32
Cosmos DB backup settings
[
{
"_comment" : ["This is a sample object that should be modified for deployment.",
"Connect strings will need to be inserted and correct service, database and collection",
"names included as well as setting the database backup flag to true as needed."],
"service" : {
"name" : "<name of your cosmos db service>",
"connectString" : "<read-only connect string here>",
"databases" : [ {"name" : "database1",
@sqldeployhelmet
sqldeployhelmet / CosmosDBBkup.ps1
Created October 2, 2019 04:11
Powershell to backup a CosmosDB
<#
This script will call the cosmos db migration tool with the correct parameters based
on a list of databases that need to be backed up. It depends on a json param file that
contains the list of cosmos db services that have databases that require backup.
This script has a couple of dependencies:
(1) the dt.exe that it runs (the cosmos db migration tool and we assume the associated files/dlls
in the compiled folder) needs to be locally available.
@sqldeployhelmet
sqldeployhelmet / NVARCHARdownsample.sql
Last active April 29, 2019 21:04
Converting an NVARCHAR to VARCHAR for fun and profit
/* Preface the string with N or
SQL will pre-emptively destroy
the data before storing the string */
DECLARE @nv AS NVARCHAR(10) = N'╥«┘{║‼℈≠'
, @v AS VARCHAR(10);
SELECT @nv, CAST(@nv AS VARCHAR(10));
/* And by reassigning we can see
the data is permanently lost */