Skip to content

Instantly share code, notes, and snippets.

View thebentern's full-sized avatar

Ben Meadors thebentern

View GitHub Profile
@thebentern
thebentern / SQL-To-DataTable.cs
Last active February 13, 2016 21:39 — forked from hanssens/SQL-To-DataTable.cs
[C#] SQL Query to Databable to CSV
// Simple example for
// 1.) Read a sql server query to datatable;
// 2.) Export it to .csv
class Program
{
static void Main(string[] args)
{
var connectionString = @"data source=bla bla bla";
var selectQuery = "select * from my-table;";
Add-Type -AssemblyName System.Web
function New-Title {
param(
[Parameter(ValueFromPipeline=$true)]
$title
)
Process {
@{title=$title}
}
@thebentern
thebentern / TSQL-to-POCO
Created October 6, 2023 21:42 — forked from joey-qc/TSQL-to-POCO
A simple TSQL script to quickly generate c# POCO classes from SQL Server tables and views. You may tweak the output as needed. Not all datatypes are represented but this should save a bunch of boilerplate coding. USAGE: Run this query against the database of your choice. The script will loop through tables, views and their respective columns. Re…
declare @tableName varchar(200)
declare @columnName varchar(200)
declare @nullable varchar(50)
declare @datatype varchar(50)
declare @maxlen int
declare @sType varchar(50)
declare @sProperty varchar(200)
DECLARE table_cursor CURSOR FOR