def exec_sp(stmt)
      klass = self.class.name
      if klass == 'ActiveRecord::ConnectionAdapters::SQLServerAdapter'
        rex = /^exec(?:ute)?\s+[\["]?(?<PROC>[a-z][a-z0-9_]*)[\]"]?(?<ARGS>\s.*)?$/i
        match = rex.match(stmt)
        if match
          exec_query("DECLARE @RET INTEGER; EXECUTE @RET=[#{match['PROC']}]#{match['ARGS']}; SELECT @RET AS [RET]").first['RET']
        else
          execute stmt
        end
      else
        execute stmt
      end
    end
def exec_sp(stmt)
      klass = self.class.name
      if klass == 'ActiveRecord::ConnectionAdapters::SQLServerAdapter'
        rex = /^exec(?:ute)?\s+[\["]?(?<PROC>[a-z][a-z0-9_]*)[\]"]?(?<ARGS>\s.*)?$/i
        match = rex.match(stmt)
        if match
          exec_query("DECLARE @RET INTEGER; EXECUTE @RET=[#{match['PROC']}]#{match['ARGS']}; SELECT @RET AS [RET]").first['RET']
        else
          execute stmt
        end
      else
        execute stmt
      end
    end
Executes a stored procedure.

 For MS SQL Server, this will return the return value from the procedure.
 For other providers, this is the same as +execute+.