Create stored-procedure

Thanks to Michelle Ufford @sqlfool on Twitter for the majority of this code!