Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / Data Porters set to auto truncate columns.sql
Created January 10, 2017 21:54
Best practice for Markit EDM Data Porters is to turn off auto truncate. But the default settings turn it on. This query finds Data Porters with the setting turned on
SELECT DP.NAME,
m.c.value('ProcType[1]', 'varchar(max)') AS ProcType,
m.c.value('AutoTruncate[1]', 'varchar(max)') AS AutoTruncate,
m.c.value('Name[1]', 'varchar(max)') AS [Input Name]
FROM [CADIS_SYS].[DP_DATAPORT] DP
CROSS APPLY DP.[DEFINITION].nodes('CadisXml/Content/Inputs/list/Item') AS m(c)
WHERE m.c.value('AutoTruncate[1]', 'varchar(max)') = 'True'
@aroder
aroder / spDmRealign
Created January 4, 2017 21:09
Stored Procedure for Markit EDM Realign
if exists (select 1 from INFORMATION_SCHEMA.ROUTINES where ROUTINE_SCHEMA = 'dbo' and ROUTINE_NAME = 'spDmRealign')
drop procedure dbo.spDmRealign
go
create procedure dbo.spDmRealign
@oldCadisId int,
@newCadisId int, /* Set @newCadisId = 0 below to get a *new* CadisID generated and assigned, or alternatively set to an existing target CadisID */
@matcherName nvarchar(100),
@sourceName nvarchar(100)
as begin
@aroder
aroder / GetInfoOnPrimaryKey.sql
Created November 18, 2016 16:42
SQL - Query to get detailed info on primary keys
SELECT
PK.CONSTRAINT_NAME,
COLS.TABLE_SCHEMA,
COLS.TABLE_NAME,
COLS.COLUMN_NAME,
COLS.DATA_TYPE,
COLS.COLUMN_DEFAULT,
COLS.CHARACTER_MAXIMUM_LENGTH,
COLS.NUMERIC_PRECISION,
COLS.IS_NULLABLE,
@aroder
aroder / Reset Matcher.sql
Created September 27, 2016 21:32
Reset the Markit EDM Matcher. Originally from https://supportlibrary.markit.com/display/EDM/Data+Matcher+Scripts, but that script throws an error if executed more than once on the same matcher
drop table cadis_proc.dm_mp7_result_temp
drop table cadis_proc.dm_mp7_result_audit_temp
drop table cadis_proc.dm_mp7_proposed_temp
exec SPDM_CLEARRESULTS @ProcessName = 'TESTER2', @SourceName = 'All', @ResetIds = 1, @PrintOnly = 0
@aroder
aroder / fnDbVars.sql
Last active August 9, 2016 14:07
fnDbVars - get database variables from Markit EDM database
/**
summary:
fnDbVars returns database variable names and values from a Markit EDM database
parameters:
- name : variableName
type: nvarchar(MAX)
description: the name of the database variable you want returned
ifNull: the function will return all database variables
author: Adam Roderick
examples:
@aroder
aroder / install_ffmpeg_with_librtmp.sh
Last active July 29, 2021 15:58
shell script to install FFmpeg with librtmp, which is necessary to use it with DaCast. Much of this comes from http://help.dacast.com/hc/en-us/articles/202357380-Stream-on-DaCast-under-Linux-with-ffmpeg
#!/bin/bash
# this scripts assumes Ubuntu 14.04 LTS
# ensure the following sources are in /etc/apt/sources.list
# deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
# deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
@aroder
aroder / eclgautologin.js
Created March 18, 2011 20:19
auto login to the test page
!(function(d) {
d.getElementsByName('clientstring')[0].value = 'parku';
d.getElementsByName('courseid')[0].value = '2022037';
d.getElementsByName('pagetoload')[0].selectedIndex = 1;
d.forms[0].submit();
})(document);
/* paste into a bookmarklet javascript: <the code> */