Skip to content

Instantly share code, notes, and snippets.

View matt40k's full-sized avatar

Matt Smith matt40k

View GitHub Profile
@matt40k
matt40k / DropIfExistsTableBug.sql
Created September 6, 2018 08:36
Demo code for the DROP TABLE IF EXISTS "bug"
DROP TABLE IF EXISTS dbo.ObjectFormerlyATable;
CREATE TABLE dbo.ObjectFormerlyATable
(
ID INT IDENTITY(1,1) NOT NULL
CONSTRAINT PK_dbo_ObjectFormerlyATable PRIMARY KEY CLUSTERED (ID ASC)
);
INSERT INTO dbo.ObjectFormerlyATable DEFAULT VALUES;
https://lunrjs.com/docs/index.html
@matt40k
matt40k / AggregationMemoryLimit.sql
Created June 25, 2018 12:15
Tuning Analysis Services (SSAS) for better Parallel Aggregation/Index Processing - http://geekswithblogs.net/ManicArchitect/archive/2010/11/02/142558.aspx
-- Reference: http://geekswithblogs.net/ManicArchitect/archive/2010/11/02/142558.aspx
-- number processing cores
DECLARE @noCores TINYINT = (
select COUNT(1)
from sys.dm_os_schedulers
where status = 'VISIBLE ONLINE'
)
SELECT
AggregationMemoryLimitMax=ceiling(100/(@noCores-2))
@matt40k
matt40k / openbanking_atms_branches.txt
Last active February 11, 2019 20:41
Open Banking - Atms and Branches
https://api.hsbc.com/open-banking/v2.1/atms
https://api.hsbc.com/open-banking/v2.1/branches
https://api.lloydsbank.com/open-banking/v2.1/atms
https://api.lloydsbank.com/open-banking/v2.1/branches
#https://openbanking.santander.co.uk/sanuk/external/branches
https://atlas.api.barclays/open-banking/v2.1/atms
https://atlas.api.barclays/open-banking/v2.1/branches
@matt40k
matt40k / civoFw.ps1
Created June 2, 2018 16:40
Configure Civo firewall
# Config
$api_key = ""
$cf_ip4_url = "https://www.cloudflare.com/ips-v4"
$cf_ip6_url = "https://www.cloudflare.com/ips-v6"
$api_domain = "api.civo.com"
$api_version = "v2"
$fw_id = ""
DECLARE
@oldname varchar(255) = '<old_name>'
,@newname varchar(255) = '<new_name>';
UPDATE
msdb.dbo.sysjobsteps
SET
command = REPLACE(command, @oldname, @newname)
WHERE
command LIKE '%'+@oldname+'%';
@matt40k
matt40k / Roger.cs
Created April 10, 2018 20:51
Roger, roger
using System.Diagnostics;
namespace Roger
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0)
{
$dir = "c:\tmp"
$csvFile = "c:\tmp\result.csv"
# Reference: https://raw.githubusercontent.com/magnusneck/SsisPowershellTools/master/Get-SsisSql.ps1
<#
.Synopsis
Extract SQL queries from SSIS (dtsx) files.
.DESCRIPTION
Extracts SQL queries from SQL Server Integration services (dtsx) files.
@matt40k
matt40k / SQLEA_Jan18_SQL2017_Linux.txt
Created January 23, 2018 21:34
Code snippet from David Williams @smooth1x1 presentation at the Jan'18 - East Anglia SQL Server User Group - SQL Server 2017 on Linux
systemctl status mssql-server
runas /netonly /user:WIN-PDNIP9N5COG\justdave “C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe”
-- Backup/Restore
CREATE DATABASE justdave;
BACKUP DATABASE justdave TO DISK = 'C:\x\justdave.bak';
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
test|test|test
test|test|test
test|test|test
test|test|test
test|test|test||Something|Dark|Side
test|test|test