header image

Access: Remove Stored Procedure

Posted by: | March 7, 2010 | 1 Comment |

We have seen how to create and use a stored procedure – but as part of our usage patterns we need to be able to delete stored procedures as well.

001
002
003
004
005
006
007
008
009
010
011
012
013
function Remove-AccessStoredProcedure {
# .ExternalHelp Maml-AccessFunctions.XML
[CmdletBinding()]
param (
    [System.Data.OleDb.OleDbConnection]$connection,
    [string]$name
)
    $sql = "DROP PROCEDURE $name"
    Write-Debug $sql
   
    $cmd = New-Object System.Data.OleDb.OleDbCommand($sql, $connection)
    $cmd.ExecuteNonQuery()   
}

 

Simple function to pass the name of the procedure and call a DROP ROCEDURE statement.

 

under: PowerShellV2

1 Comment

  1. By: dvdrip on March 11, 2010 at 8:40 pm      

    Thank you very much for sharing this. I sometimes have problem of removing the stored procedure.It is helpful.