Skip to content

Instantly share code, notes, and snippets.

View kmoormann's full-sized avatar

Kevin Moormann kmoormann

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace MyProject.Helpers
{
@kmoormann
kmoormann / IterateResultSetSSIS.cs
Created August 31, 2012 18:58
Iterate over a result set in SSIS
//be sure to reference System.Xml;
//need a using using System.Data.OleDb;
//set up an adapter and a data table to iterate over
var resultsAdapter = new OleDbDataAdapter();
var resultsTable = new DataTable();
resultsAdapter.Fill(resultsTable, Dts.Variables["ZipCodesResultSet"].Value);
var list = new StringBuilder();
int count = 0;
@kmoormann
kmoormann / AccessSSISVariableInScriptTask.cs
Created August 31, 2012 17:54
How to access SSIS variables in Script Task
//note that variable name spaces are not to be used and variables are case sensitive
object myVar = Dts.Variables["MyCaseSensitiveVariableName"].Value;
@kmoormann
kmoormann / gist:3504218
Last active October 9, 2015 12:17
ssis time string concatenation
(DT_WSTR, 4) YEAR( @[System::StartTime] )
+ "-"
+ (DT_WSTR, 1)( MONTH( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 4) MONTH ( @[System::StartTime] )
+ "-"
+ (DT_WSTR, 1)( DAY( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 4) DAY ( @[System::StartTime] )
+ " "
+ (DT_WSTR, 1)( DATEPART( "Hour" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 2) DATEPART( "Hour" , @[System::StartTime] )
@kmoormann
kmoormann / CopyFilesInFolder.ps1
Created August 20, 2012 19:17
CopyFilesByExtension
function Global:CopyFilesInFolder([string] $FromDir, [string] $ToDir, [string] $FileExtension)
{
#Destination for files
$From = $FromDir + "*" + $FileExtension
Copy-Item $From $ToDir
}
@kmoormann
kmoormann / ClearDir.ps1
Created August 15, 2012 16:35
PowerShell delete all items in directory and all subdirectories
function Global:ClearDir([string] $PATH)
{
$AllItemsInPath = $Path + "*"
Remove-Item $AllItemsInPath -recurse -force
}