Oct 23 2012 5:52PM GMT
Posted by: Colin Smith
Database
PowerShell Table and Index DDL
Posted by: Colin Smith
sqlscript-options
$server = “Instance”
$tables = “Table Name”
connect-sql $server
$db = $s.databases | where {$_.name -eq “EventManagement_Test”}
$db.name
foreach ($table in $tables)
{
$outdir = “C:\ddl\$server”
if (!(Test-Path $outdir))
{
New-Item -ItemType container $outdir
}
$tbl = $db.Tables | where {$_.Name -eq $table}
$name = $tbl.name
$tbl.Script($so) | Out-File $outdir/$table.sql -Append
}




