Skip to content

Instantly share code, notes, and snippets.

View QuadmanSWE's full-sized avatar

David Söderlund QuadmanSWE

View GitHub Profile
@QuadmanSWE
QuadmanSWE / tvp-demo.ps1
Created May 6, 2026 14:31
An example of inserting batches of data using table valued parameters through a straight sql query
Import-Module dbatools.library
Import-Module dbatools
# A dbatools implementation of using tvp to insert large amounts of data to SQL Server, using PowerShell as the client language.
# Inspired by https://timdeschryver.dev/blog/faster-sql-bulk-inserts-with-csharp
# Local environment variables for this experiment
$password = Read-Host -Prompt "Enter sysadmin(sa) password for local SQL Server instance" -AsSecureString
$instance = Connect-DbaInstance -SqlInstance '127.0.0.1,1433' -SqlCredential (New-Object System.Management.Automation.PSCredential('sa', $password))
$databaseName = 'mydatabase'
@QuadmanSWE
QuadmanSWE / remove-user-objects-from-master.sql
Created November 23, 2022 07:26
remove all user objects from master
USE MASTER
GO
SET NOCOUNT ON
GO
SELECT N'ALTER TABLE [' + schema_name([schema_id]) + N'].[' + object_name(parent_object_id) + N'] DROP ' + [name] command from sys.objects where [type] = 'F' AND is_ms_shipped <> 1
UNION ALL
SELECT 'GO' command
UNION ALL
@QuadmanSWE
QuadmanSWE / dotnet.dockerfile
Created March 30, 2022 21:52
multi stage docker builds of web apps
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine3.15@sha256:fe38d256de00db2594c5d3949df4d06a7801ff03bbbdf084d2ce5f0a2e7c747b AS builder
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.15@sha256:eaab307e3325a298998647d6f2916b68d5445ffbbd470d053808786427bc6456 as bin
WORKDIR /app