views:

26

answers:

1

I have several stored procedures that all use the same set of parameters. Is there a way to define and save the parameter list as a reusable block of code? Something like this:

CREATE PROCEDURE test
    Using StoredParameterList 
AS
BEGIN
    SQL Statement
END

Is this possible? It would make code maintenance easier if a parameter needed to be changed.

A: 

Well, sort of. I've never used them, but Sql Server supports something called User Defined Types. I suspect you can create a user-defined type that represents your parameter list and then just have one parameter on each procedure with UDT.

Joel Coehoorn
While Joel is correct, I would strongly advise against using UDT's (User Defined Types) in SQL. There are many subtle limitations to them, that can be severely constraining down the road. Simply put, persistent data is ***not*** like persistent code and cannot (and should not) be managed in the same way. In SQL, data considerations must come first, not code considerations. And yes, this does mean that sometimes you end up with apparent code redundancies.
RBarryYoung