Skip to content

Instantly share code, notes, and snippets.

View ekkis's full-sized avatar

Erick Calder ekkis

  • Arix Int'l
  • LalaLand
View GitHub Profile
You can now send me #bitcoin here: https://onename.io/ekkis
Verifying that +ekkis is my Bitcoin username
@ekkis
ekkis / Split
Last active August 29, 2015 14:23
String functions for T-Sql
if object_id('Split') is not null
drop function Split
go
create function Split(@s varchar(max))
returns @ret table (s varchar(max))
as
begin
insert @ret select s from SplitByString(@s, ',')
return
end
@ekkis
ekkis / SQLRegEx.cs
Last active August 29, 2015 14:23
Using regular expressions in SQL Server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using System.Text.RegularExpressions;
public class SQLREGEX
{
@ekkis
ekkis / db.ps1
Created June 16, 2015 18:10
SQL Server connectivity abstraction
$script:dsn = @{
"Data Source" = "{0}";
"Initial Catalog" = "{1}";
"Integrated Security" = "SSPI";
"Application Name" = "PSH Client"
}
function SQLDSN($srv, $db, $dsn = @{}) {
$script:dsn.Keys |%{ if (!$dsn[$_]) { $dsn[$_] = $script:dsn[$_] } }
$dsn = $dsn.Keys |%{ "{0}={1}" -f $_, $dsn[$_] }
@ekkis
ekkis / Json2db.ps1
Last active August 29, 2015 14:23
Inserts Json structures into a SQL Server database
Param($fn, [switch] $show = $false, $srv = "localhost", $db = "tempdb", $tb = "ListDictionary")
#
# - synopsis -
# receives a file of jason objects listed one per line, flattens
# the structure such that arrays and embedded hashes get promoted
# to the top, and generates SQL or runs the SQL to insert the
# records into the given database
#
# - syntax -
@ekkis
ekkis / DLLCallTree.ps1
Created June 16, 2015 18:45
Generates a call tree for one or more assemblies, optionally storing the information in a SQL Server database
#
# - Synopsis -
#
# This script allows generation of a call tree on one or more
# assemblies and may optionally store said information in database
# tables
#
# - Syntax -
# -assemblies {list}
# a list of comma-delimited paths. If not provided
@ekkis
ekkis / CodeMetrics.ps1
Created June 16, 2015 18:47
Generates code metrics information for a given assembly
# For documentation please refer to:
# http://la-elitedocs.elitecorp.com/wiki/index.php?title=Metrics.ps1
# Needs the Visual Studio Code Metrics PowerTool 10.0 installed
# http://www.microsoft.com/en-us/download/details.aspx?id=9422
param([switch] $lib = $false, $filter = "*", $inst = "PMQJMDEV", [switch] $debug = $false, [switch] $sql = $false)
$global:M = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Metrics.exe"
$global:WebUIBin = "\\la-se-wapi-test\TE_3E_Share\TE_3E_$inst\Inetpub\WebUI\bin"
function global:GetMetrics($f) {
if object_id('MkPrimaryKey') is not null
drop proc MkPrimaryKey
go
create proc MkPrimaryKey
@TblName sysname
, @ColNames varchar(max)
, @exec bit = 1
, @display bit = 0
as
set nocount on
@ekkis
ekkis / sp_dbkill.sql
Created June 16, 2015 18:52
Kills all connections active on a given database
use master
go
if object_id('sp_dbkill') is not null
drop proc sp_dbkill
go
/*
** - synopsis -
** Kills all connections active on a given database
**
** - business requirement -
@ekkis
ekkis / VMs.sql
Created June 16, 2015 18:54
Functionality for VM analysis
/*
create table #counts (name sysname, n int)
go
declare @s varchar(max)
select @s = isnull(@s, '') + ' insert #counts select ''' + name + ''', count(*) from ' + name from sys.tables
exec(@s)
select * from #counts where n >= 16 order by 2
select * from vpx_object_type
select * from vpx_feature
select * from vpx_sequence order by id