Not sure if this is helpful, but I have created several procs that I use when connecting to MSSQL, which I do for a good portion of my applications.

Here is an example of one.

This is a proc...