| Author |
Topic |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-12-12 : 10:18:31
|
| I splitted 1 big SP into 12 Sub SPs. Is that something common?the 1 big SP was too big and confussing. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-12 : 10:22:14
|
| No, it is not.But I suspect there is something bloated with your SP. Unless you mean your STREET ADDRESS alteration SP.Peter LarssonHelsingborg, Sweden |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2006-12-12 : 10:29:30
|
| Unless I'm missing the point here, I've always thought writing modular code is a fairly common practice. If you've one monster procedure that's performing a multitude of different functions, ime there's lots of benefits to making breaking it down into smaller more clearly defined procs...Mark |
 |
|
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-12-12 : 10:33:59
|
| yes its my street address sp.its huge. i had to splitted it. i have around 12 sub sp which split individual fields. so now every sub SP Split an individual field.if its not common. should i leave it as one huge SP? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-12 : 10:42:33
|
| No, in your case 12 sub-SP should be enough. I have seen some of the code...I was refering to the shear number (12) sub-SPs. In my professional life, I sometimes have to call 2, maybe three sub-SP.Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-12 : 11:26:25
|
| Also you can have wrapper procedure which exceutes all other proceduresCreate procedure BigProcedureasEXEC sp1 -- parametersEXEC sp2 -- parameters..MadhivananFailing to plan is Planning to fail |
 |
|
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-12-12 : 13:18:34
|
| In my pro life. i seen 1 SP calling 5 SPs. And one of the sub SP was longer than the parent one.My SP dont have Parameters. is it normal? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-12-12 : 14:12:26
|
"I've always thought writing modular code is a fairly common practice"Yeah, me too, but the overhead of calling child-Sprocs seems to go against the grain of "performance". We do do it now-and-again, but certainly not for the convenience of making the code more reasonable - which, OTOH, we do do in our application languages.Pity really, because it would make the SQL more maintainable.However, I do think that:IF @Param1 = 'SEARCH'BEGIN SELECT * FROM MyTable WHERE MyKey = @PARAM2ENDELSE IF @Param1 = 'UPDATE'BEGIN UPDATE MyTable SET MyCol1 = 'FOO' WHERE MyKey = @PARAM2END is better replaced withIF @Param1 = 'SEARCH'BEGIN EXEC dbo.usp_XXX_Search @SearchKey = @PARAM2ENDELSE IF @Param1 = 'UPDATE'BEGIN EXEC dbo.usp_XXX_Update @UpdateKey = @PARAM2END because the individual steps will have individual query plans cached.That we do do.There, that should give the spell checker a fit with the duplicate words!Kristen |
 |
|
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-12-14 : 16:31:14
|
| i read its not good to used nested stored procedures. Should rolled back to 1 huge stored procedure? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-14 : 16:37:11
|
| Where did you read that?Tara Kizer |
 |
|
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-12-15 : 08:09:36
|
| tkizer,http://www.sql-server-performance.com/stored_procedures.aspAvoid nesting stored procedures, although it is perfectly legal to do so. Nesting not only makes debugging more difficult, it makes it much more difficult to identify and resolve performance-related problems. [6.5, 7.0, 2000] Updated 04-03-2006 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2006-12-15 : 09:28:27
|
| Again, the answer is, it depends. In some cases it makes sense, in others perhaps not.Sounds like you may have fallen into the latter caseIt's all about the architect and their mind setIn most instances I don't have nesting...in on particular case I have about 24 "sub" sprocs...with 2 wrappers...mostly because each sub sproc is it's own unit of work and can be "restarted" be specifying the "step" when calling the wrapperI should blog that codeBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|