Skip to content

Instantly share code, notes, and snippets.

@aroder
aroder / FindReferences.sql
Created February 15, 2017 18:20
Find references to a column *anywhere* in SQL Server. Uses text search rather than hard dependencies. Originally from http://stackoverflow.com/questions/1883700/in-sql-server-how-can-i-find-everywhere-a-column-is-referenced, answer by Anar Khalilov
SELECT sys.objects.object_id,
sys.schemas.NAME AS [Schema],
sys.objects.NAME AS Object_Name,
sys.objects.type_desc AS [Type]
FROM sys.sql_modules(NOLOCK)
INNER JOIN sys.objects(NOLOCK) ON sys.sql_modules.object_id = sys.objects.object_id
INNER JOIN sys.schemas(NOLOCK) ON sys.objects.schema_id = sys.schemas.schema_id
WHERE sys.sql_modules.DEFINITION COLLATE SQL_Latin1_General_CP1_CI_AS LIKE '%.PartyTitleTxt%' ESCAPE '\'
ORDER BY sys.objects.type_desc,
sys.schemas.NAME,
@aroder
aroder / ClearDataFlowSourceMonitor.sql
Created March 20, 2017 20:17
SQL Script to clear data from the Markit EDM Data Flow source monitor tables.
-- will contain data about the data flow source monitor tables
DECLARE @tableInfo TABLE (
table_id INT identity(1, 1), -- a unique identifier we will use to loop over the tables
table_name NVARCHAR(max) -- the name of the table in question, used to build the dynamic query while in the loop
)
-- popuplate the table with the names of tables used to store source monitor info for the data flows
INSERT @tableInfo
SELECT table_name
FROM INFORMATION_SCHEMA.TABLES
@aroder
aroder / removeIdentitySpecification.sql
Created June 8, 2017 12:18
Remove IDENTITY specification from column
BEGIN TRY
-- removing IDENTITY specification from master table. Premaster table will have IDENTITY specification, and the ID will carry forward to the master table
BEGIN TRANSACTION REMOVE_IDENTITY_SPEC
CREATE TABLE [dbo].[MstrInvAssetPartyRoleRel_withoutIdentitySpecification] (
[InvAssetPartyIDNum] [int] NOT NULL,
[InvAstIdNum] [int] NOT NULL,
[PartyRoleRelIDNum] [int] NOT NULL,
[CADIS_SYSTEM_INSERTED] [datetime] NULL,
[CADIS_SYSTEM_UPDATED] [datetime] NULL,
@aroder
aroder / sqlYamlParser.ps1
Created October 30, 2017 14:57
SQL YAML Documentation Parser
param (
[string]$output = "wiki", # can be html or wiki
[string]$DatabaseServer = "nt7565",
[string]$Database = "MARKITEDM_DEV_DX"
#[Parameter(Mandatory=$true)][string]$username,
#[string]$password = $( Read-Host "Input password, please" )
)
Clear-Host
(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
@aroder
aroder / Dockerfile
Last active December 17, 2017 14:59
botpress Dockerfile
# comes with node and npm already installed
FROM node:carbon-alpine
RUN mkdir -p /usr/src/app
RUN chown node:node /usr/src/app
WORKDIR /usr/src/app
USER node
# ensures both package.json and package-lock.json are copied
COPY package*.json ./
RUN npm install --quiet --production --no-progress && \
@aroder
aroder / script.sql
Created February 1, 2018 21:58
Diff 2 tables from different databases
WITH A AS (
SELECT *
FROM OPENROWSET('SQLNCLI', 'Server=<SERVERA>;Database=CADIS;Trusted_Connection=yes;', 'select top 10 * from <TABLE>')
),
B AS (SELECT * FROM <TABLE>),
A_ONLY AS (
SELECT TOP 10 * FROM A
EXCEPT
SELECT TOP 10 * FROM B
@aroder
aroder / remove_all_docker_containers.bat
Created September 27, 2019 05:51
Remove all docker containers
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
@aroder
aroder / s3_multipart_upload.py
Created July 8, 2020 01:54 — forked from teasherm/s3_multipart_upload.py
boto3 S3 Multipart Upload
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB
PART_MINIMUM = int(5e6)
"""Run this script to create or refresh your developer environment
Installs a virtual environment with the main requirements at venv, one at venv/dbt, and one at venv/meltano. The root (venv) can be changed by passing an argument e.g. "python requirements/developer_setup.py my_venv_root"
To run: python developer_setup.py
"""
import glob
import os
import pip
import re
import shutil
import subprocess
import base64
import json
import multiprocessing
import sys
import boto3
import botocore
INPUT_FILE = 'all_raw_files.txt'
S3_RAW_BUCKET_NAME = '____'