Wednesday, March 28, 2012

OK to use one stored procedure for inserts and updates?

I have seen a couple examples where the person used ONE stored procedure (call it SaveOrder) was used for both Inserts and Updates. This would be opposed to having a InsertOrder and UpdateOrder. I'm assuming there was some branching code in there to determine whether the record already existed or not.

My question is this: Is this a good practice? It seems like it might save some duplicate coding.

Just looking for some opinions-

Thanks,

Jim

its ok....

if exist...update

else insert

|||Hi,

I would alway prefer a more granular solution rather than a monolithic approach. Otherwise procedure could get (depending on your code) hard to read and debug.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Thank you both-

Jim

sql

No comments:

Post a Comment