Created
May 4, 2010 18:29
-
-
Save underwhelmed/389767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$server = "localhost"; # The SQL Server instance name | |
$database = "MyDB"; # The database name | |
# Load the SMO assembly | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null | |
# Create the SMO objects | |
$srv = New-Object "Microsoft.SqlServer.Management.SMO.Server" $server; | |
$db = New-Object ("Microsoft.SqlServer.Management.SMO.Database"); | |
# Get the database | |
$db = $srv.Databases[$database]; | |
# For each stored procedure in the database | |
foreach($proc in $db.StoredProcedures) | |
{ | |
# NOTE: my stored procedures are all prefixed with "web_" | |
if ($proc.Name.StartsWith("web_")) | |
{ | |
$proc.TextBody = $proc.TextBody; | |
$proc.Alter(); | |
Write-Host "Altered " $proc.Name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment