calling a stored procedure from activerecord

Assuming user class:

User.connection.execute(“exec myproc.sp ‘param’”)

So basically, just like you would in any other language. However, I’d bury this.

class User < ActiveRecord::Base

def self.myproc(param)
self.connection.execute(“exec myproc ‘#{param}’”)


That way you can call


When you call that, you get back a Mssql::Result class. You’ll need to look at the api docs to figure out how to retrieve records, but it’s basically a collection (think array)