Posts

Showing posts from 2011

Getting unique table using PowerShell and SQL SMO

When accessing tables property of database in SMO, tables are indexed using name (excluding schema) This is problematic when using different schemas. To access a table using unique name use the following code $instance = $args[0]  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $srv = new-Object Microsoft.SqlServer.Management.Smo.Server($instance) $db=$srv.Databases["ExampleDatabase"] $table = $db.Tables["ExampleTable"] # will get dbo schema, or random?   $table = $db.Tables | Where-Object {$_.Schema -eq "dbo" -and $_.Name -eq "ExampleTable"} #will get your unique table

Mainframe encoding Finland/Sweden

const string IbmEbcdicFinlandSwedenEuro = "IBM01143"; Encoding encoding = Encoding.GetEncoding(IbmEbcdicFinlandSwedenEuro);