Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PowerShell scripting SMO

Status
Not open for further replies.

onderbain

MIS
Oct 12, 2007
1
US
I want to modify the below to script stored procedures. I replaced (tables with SP) but apparently the syntax is wrong. Also, I'd like to be able to run below for a specific (Schema.SP). Any help is much appreciated.

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null
$MyScripter=new-object ("Microsoft.SqlServer.Management.Smo.Scripter")
$srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "Server\database"
$MyScripter.Server=$srv
$so=$MyScripter.Options
$so.FileName="C:\Database\SCRIPTS\PowerShell\SharedDimensions\filename.sql"
$MyScripter.Script($srv.Databases["adventureworks"].tables)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top