IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Interesting question.
Here's another view: https://msdn.microsoft.com/en-us/library/ms973918.aspx

Maintainability and Abstraction

The second potential benefit to consider is maintainability. In a perfect world, your database schema would never change and your business rules would never get modified, but in the real world these things happen. That being the case, it may be easier for you if you can modify a stored procedure to include data from the new X, Y, and Z tables that have been added to support that new sales initiative, instead of changing that information somewhere in your application code. Changing it in the stored procedure makes the update transparent to the application — you still return the same sales information, even though the internal implementation of the stored procedure has changed. Updating the stored procedure will usually take less time and effort than changing, testing, and re-deploying your assembly.

Also, by abstracting the implementation and keeping this code in a stored procedure, any application that needs access to the data can get it in a uniform manner. You don't have to maintain the same code in multiple places, and your users get consistent information.

Another maintainability benefit of storing your T-SQL in stored procedures is better version control. You can version control the scripts that create and modify your stored procedures, just as you can any other source code module. By using Microsoft Visual SourceSafe® or some other source control tool, you can easily revert to or reference old versions of the stored procedures.

One caveat with using stored procedures to enhance maintainability is they cannot insulate you from all possible changes to your schemas and rules. If the changes are large enough to require a change in the parameters fed into the stored procedure, or in the data returned by it, then you are still going to have to go in and update the code in your assembly to add parameters, update GetValue() calls, and so forth.

Another issue to consider is that using stored procedures to encapsulate business logic limits your application portability, in that it ties you to SQL Server. If application portability is critical in your environment, encapsulating business logic in a RDBMS-neutral middle tier may be a better choice.


It sounds like there are trade-offs (as always).

Cheers,
Scott.
New Better to manage that sort of problem through services
Stored procedures can be considered services, sure, but you run a maintainability cost just by virtue of how database servers work.
Regards,
-scott
Welcome to Rivendell, Mr. Anderson.
     Are stored procs "hiding functionality"? - (drook) - (23)
         wag, the same as a shared library, you dont know where it came from -NT - (boxley)
         Interesting question. - (Another Scott) - (1)
             Better to manage that sort of problem through services - (malraux)
         Depends on how they're managed. - (malraux) - (10)
             And don't forget about sp's providing better performance on the database. -NT - (mmoffitt) - (9)
                 That depends - (malraux) - (8)
                     For OLTP applications, I disagree, with MS Sql Server anyway. - (mmoffitt) - (7)
                         Performance is the least of my concerns at this point - (drook) - (1)
                             Until it isn't any more. :-) - (malraux)
                         Performance != throughput - (malraux) - (4)
                             Interesting - (drook) - (2)
                                 I've looked at DB scale out, though not recently. - (static)
                                 Eventually the amount of work exceeds the capacity of a single machine to do it - (malraux)
                             sure, lets take the speed out of the cpu and replace it in multiple small connected units, :-) -NT - (boxley)
         Implementation detail, someone else's problem. - (pwhysall)
         Who is responsible for what? - (crazy) - (5)
             I'm coming down on the side of your data integrity comment - (drook) - (4)
                 Sounds like a management problem. - (static) - (2)
                     You think? - (drook) - (1)
                         Not surprised at all. - (static)
                 Someone's going to be writing something that deals with integrity. - (malraux)
         Re: Are stored procs "hiding functionality"? - (mvitale) - (1)
             I used utPLSQL in a former life. - (malraux)

And let's have a little taste of that old computer-generated... swagger... yes.
52 ms