Skip to content

Instantly share code, notes, and snippets.

View shaneis's full-sized avatar
🎯
The mind isn't a cup to fill but a fire to feed...my whiskey cup is empty tho...

Shane O'Neill shaneis

🎯
The mind isn't a cup to fill but a fire to feed...my whiskey cup is empty tho...
View GitHub Profile
USE [Wordle];
GO
DROP TABLE IF EXISTS #KnownLetters, #AllAnswers;
GO
DECLARE
@known_letters AS varchar(5),
@excluded_letters AS varchar(26),
@position1 AS char(1),
@shaneis
shaneis / create_wordle_table.sql
Created April 11, 2023 21:26
Create table and query the results for wordle answers
/* Create table */
IF NOT EXISTS
(
SELECT *
FROM [sys].[tables] AS [t]
JOIN [sys].[schemas] AS [s]
ON [t].[schema_id] = [s].[schema_id]
WHERE
[t].[name] = N'WordleAnswers'
AND [s].[name] = N'dbo'
@shaneis
shaneis / JobStatus.sql
Last active October 11, 2022 21:20
Dynamic SQL T-SQL Tuesday 155.sql
DECLARE
@job_sql AS nvarchar(max),
@job_name AS nvarchar(128) = N'syspolicy_purge_history', -- = N'No existy',
@debug_mode_on AS bit = 1; -- 0;
DECLARE
@nl AS nchar(2),
@actual_job_name AS nvarchar(128);
/* Newline for formatting */
package main
import (
"database/sql"
"fmt"
"log"
// this is the driver & yes, even though we're throwing
// it away to `_`, it's still needed
_ "github.com/denisenkom/go-mssqldb"
USE tempdb;
GO
IF OBJECT_ID(N'dbo.LollerCoaster', N'U') IS NOT NULL BEGIN
DROP TABLE dbo.LollerCoaster;
END;
GO
CREATE TABLE dbo.LollerCoaster (
loller_coaster_id tinyint IDENTITY(1, 1) NOT NULL,
loller_coaster_stage varchar(4000) NOT NULL
);
describe 'testing our function with scriptroot' {
# Get our self contained script info.
. .\Get-FunctionInfo.ps1
$fInfo = Get-FunctionInfo -Path .\Get-NameScriptBlock.ps1
# Create something we can dot-source.
$Fake = "function $($fInfo.Name) { $($fInfo.Definition) }"
$FakeFunc = [scriptblock]::Create($Fake)
. $FakeFunc
@shaneis
shaneis / Get-Name.ps1
Created February 22, 2019 14:58
Get-Name with extra for ScriptBlock
function Get-Name {
[CmdletBinding()]
param(
[String]$Name = 'you'
)
'Hello, {0}. Script root is {1}' -f $Name, $PSScriptRoot
}
Get-Name -Name Shane
DECLARE @XmlStoredAsNvarchar nvarchar(4000) = '
<EventContext>
<eventType>Save Test Data</eventType>
<discipline>Operations</discipline>
<documentNumber>1.2.3.4</documentNumber>
<documentVersion>1.0</documentVersion>
<sectionNumber>1.2.1.1</sectionNumber>
<sectionName>Test section: XML Test</sectionName>
<tableIdentifier>1</tableIdentifier>
<objectType>Object</objectType>
DECLARE @XmlStoredAsNvarchar nvarchar(4000) = '
<EventContext>
<eventType>Save Test Data</eventType>
<discipline>Operations</discipline>
<documentNumber>1.2.3.4</documentNumber>
<documentVersion>1.0</documentVersion>
<sectionNumber>1.2.1.1</sectionNumber>
<sectionName>Test section: XML Test</sectionName>
<tableIdentifier>1</tableIdentifier>
<objectType>Object</objectType>
DECLARE @XmlStoredAsNvarchar nvarchar(4000) = '
<EventContext>
<eventType>Save Test Data</eventType>
<discipline>Operations</discipline>
<documentNumber>1.2.3.4</documentNumber>
<documentVersion>1.0</documentVersion>
<sectionNumber>1.2.1.1</sectionNumber>
<sectionName>Test section: XML Test</sectionName>
<tableIdentifier>1</tableIdentifier>
<objectType>Object</objectType>