Saturday, March 3, 2007

Note to self - piping sql scripts from the directory to the osql - Powershell

Get-ChildItem C:\SomePath -recurse | Where-Object {$_.get_Extension() -eq ".sql"} |foreach {Write-Output "Executing: " $_.FullName; osql -S SqlServerName -d DatabaseName -i $_.FullName -E} > c:\SomeFileToPipeOutputTo TODO: redo to use sqlcmd as osql is not recommended anymore for the sql 2005

No comments: