Skip to content

Instantly share code, notes, and snippets.

@keithbloom
keithbloom / DropAndCreateForiegnKeys.ps1
Created February 8, 2011 10:41
A powershell script which creates a couple of SQL files to drop and re-create foreign key constraints
#See http://msdn.microsoft.com/en-us/library/cc281962.aspx
PowerShell -NoExit -Command "$HOME\Documents\WindowsPowerShell\InitializeSQLProvider.ps1"
cd SQLSERVER:\sql\`(local`)\SQLSERVER2008\Databases\AdventureWorks2008\Tables
$opts = New-Object Microsoft.SqlServer.Management.Smo.ScriptingOptions
$opts.ScriptDrops = $true
$tables = ls | where {$_.Schema -eq "Production"}
$tables | foreach {$_.ForeignKeys} | foreach {$_.Script()} >> C:\Temp\CreateKeysScript.sql
@keithbloom
keithbloom / ReflectingAnonymousTypes
Created February 7, 2011 16:19
Using anonymous types to set test data.
[TestFixture, Explicit]
public class ReflectingAnonymousTypes
{
[Test]
public void DoesItWork()
{
StudentVisa student = Build.AStudentVisa();
var props = new {FirstName = "Keith", NationalityISO = "arj"};
SetProperties(student,props);