Skip to content

Instantly share code, notes, and snippets.

View SQLDBAWithABeard's full-sized avatar
🦄
Generally bearding

Rob Sewell SQLDBAWithABeard

🦄
Generally bearding
View GitHub Profile
@SQLDBAWithABeard
SQLDBAWithABeard / Secrets_Management_with_PowerShell.ipynb
Last active February 17, 2024 01:57
Using Secrets Management
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<#
Nasty, horrible, dirty method of filling a database with duff data.
We used this for some data movement load testing into Azure
It uses Itziks method of creating a numbers table and then converts them into the right(ish)
datatype which it gets from the schema.
Nothing more No PKs, no FKs, no constraints
All dates, datetimes etc are 1901-01-01 00:00:00
@SQLDBAWithABeard
SQLDBAWithABeard / notify teams sql agent jobid convert.ps1
Last active July 27, 2020 18:09
Converting a jobid agent token and notify teams
Param(
$SqlInstance,
$JobID
)
$webhookurl = ""
function Notify-TeamsSQlAgentJob {
Param(
$SQLInstance,
$JobID,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / snippet.json
Created June 29, 2020 12:40
markdown table snippet
"Table": {
"prefix": "table",
"body": [
"| ${1:Heading1} | ${2:Heading2} | ${3:Heading3} |",
"|------------|----------------:|-----------------:|",
"| | | |"
],
"description": "Log output to console"
}
@SQLDBAWithABeard
SQLDBAWithABeard / settings.json
Last active June 17, 2020 16:51
windows terminal settings
// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@SQLDBAWithABeard
SQLDBAWithABeard / ForGitHub.ipynb
Created May 1, 2020 11:13
public github notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / notebook agent job .ps1
Created March 31, 2020 15:44
notebook Agent job powershell
$TargetDatabase = "DBA"
$JobId = "$(ESCAPE_SQUOTE(JOBID))"
$StartTime = "$(ESCAPE_SQUOTE(STRTTM))"
$StartDate = "$(ESCAPE_SQUOTE(STRTDT))"
$JSONTable = "select * from notebooks.nb_template where job_id = $JobId"
$sqlResult = Invoke-Sqlcmd -Query $JSONTable -Database $TargetDatabase -MaxCharLength 2147483647
$FirstNotebookError = ""
function ParseTableToNotebookOutput {
param (
[System.Data.DataTable]
@SQLDBAWithABeard
SQLDBAWithABeard / Grouping logins by day.ipynb
Created March 31, 2020 15:20
Extended Event group logins by day Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
CREATE EVENT SESSION [MonitorWindowsLogins] ON SERVER
ADD EVENT sqlserver.login(
ACTION(sqlserver.client_hostname,sqlserver.database_name,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.session_server_principal_name)
WHERE ([sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_nt_user],N'')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\gsartori')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\wdurkin')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\Rob')
AND [sqlserver].[session_nt_user]<>N'THEBEARD\gfritchey'
AND [sqlserver].[session_server_principal_name]<>N'THEBEARD\SQL_SVC'
AND [sqlserver].[session_server_principal_name]<>N'THEBEARD\SQL2014SER12R2$'))