Skip to content

Instantly share code, notes, and snippets.

View krcourville's full-sized avatar

Ken Courville krcourville

View GitHub Profile
@krcourville
krcourville / PromiseHelper.js
Created May 5, 2015 01:07
Example of sequentially processing an array of promises
function PromiseHelper(){}
PromiseHelper.sequentialProcess = function(promises) {
if(promises.length && promises.length > 0){
return promises.reduce( function( current, acc ) {
return current.then(acc);
});
}else {
return $.when();
}
@krcourville
krcourville / gist:a4c2a5ad2392fcbaf22a
Created July 20, 2015 15:16
Linqpad recursively print MSSQL table and related tables
const string connectionstring = @"Server=myserver;Database=mydb;Trusted_Connection=True;Connection Timeout=30;";
string dependsSql = @"
select t.name as TableWithForeignKey, fk.constraint_column_id as FK_columns , c.name as ForeignKeyColumn
from sys.foreign_key_columns as fk
inner join sys.tables as t on fk.parent_object_id = t.object_id
inner join sys.columns as c on fk.parent_object_id = c.object_id and fk.parent_column_id = c.column_id
where fk.referenced_object_id = (select object_id from sys.tables where name = @tablename)
order by TableWithForeignKey";