Listing B
Stored Procedure
Function EditSQLServerSP(oldtitle As String, newtitle As String)
  Dim strConn As String
  Dim cmd As ADODB.command
  Dim rst As ADODB.Recordset
  strConn = "Provider=SQLOLEDB;" & _
      "Server=(local);" & _
      "Initial Catalog=Northwind;" & _
      "Integrated Security=SSPI;"
  Set cmd = New ADODB.command
  With cmd
    .ActiveConnection = strConn
    .CommandText = "CREATE PROCEDURE spUpdateTitle " & _
        "@TitleNew nvarchar(30), @TitleOld nvarchar(30) " & _
        "AS " & _
        "UPDATE Employees " & _
        "SET Title = @TitleNew " & _
        "WHERE Title = @TitleOld "
    .Execute
  End With
  Set cmd = New ADODB.command
  With cmd
    .ActiveConnection = strConn
    .CommandType = adCmdStoredProc
    .CommandText = "spUpdateTitle"
    .Parameters.Refresh
    .Parameters("@TitleOld") = oldtitle
    .Parameters("@TitleNew") = newtitle
    .Execute
  End With
  Set cmd = Nothing
  rst.Close
  Set rst = Nothing
End Function